public void BRKInstruction(byte Instruction) { InstructionLength = 1; PushToStack16(PC_Register); Status_Register |= (StatusFlags)StatusFlags.B; PushToStack((byte)Status_Register); Status_Register &= (StatusFlags)StatusFlags.B; PC_Register = RAM.GetByte16(0xFFFE); Debug.WriteLine("BRK - Identifier byte: " + Instruction); }
/// <summary> /// Empty private constructor /// </summary> private FullTextLine(TextFormattingMode textFormattingMode, bool justify, double pixelsPerDip) : base(pixelsPerDip) { _textFormattingMode = textFormattingMode; if (justify) { _statusFlags |= StatusFlags.IsJustified; } _metrics = new TextMetrics(); _metrics._pixelsPerDip = pixelsPerDip; }
/// <summary> /// Sets status and broadcasts if different /// </summary> /// <param name="status"></param> protected void SetStatus(StatusFlags status) { if (Status != status) { Status = status; if (OnStatusChanged != null) { OnStatusChanged(this); } } }
protected void SetFlag(IC6502 cpu, StatusFlags flag, Func <bool> predicate) { if (predicate()) { cpu.State.SetFlag((byte)flag); } else { cpu.State.ClearFlag((byte)flag); } }
static TodoItem() { PriorityFlags.Add(PriorityFlag.High); PriorityFlags.Add(PriorityFlag.Normal); PriorityFlags.Add(PriorityFlag.Low); StatusFlags.Add(StatusFlag.NotStarted); StatusFlags.Add(StatusFlag.InProgress); StatusFlags.Add(StatusFlag.Deferred); StatusFlags.Add(StatusFlag.WaitingOnSomeoneElse); StatusFlags.Add(StatusFlag.Completed); }
private void UpdateStatus(StatusFlags status) { byteText.text = ((byte)status).ToString(); foreach (StatusFlags flag in Enum.GetValues(typeof(StatusFlags))) { if (flag == StatusFlags.None) { continue; } toggleDictionary[flag].isOn = (status == (status | flag)); } }
public void Render(Core core, StatusFlags statusFlags) { if (_data != null && _buffer != null) { Graphics gfx = Graphics.FromImage(_buffer); int x, y; if (_data.Entries.Find(e => e.Core == core, out x, out y)) { _coreView.Render(core, _interpreter.GetNextInstructionCost(core), statusFlags, _data.Entries[y, x].Color); gfx.DrawImage(_coreView.Image, x * (_coreView.Width + _coreMargin), y * (_coreView.Height + _coreMargin)); } } Invalidate(); }
private void UpdateControls() { // // General tab // applyButton.Enabled = mDirty; const string FLAGS = "CZIDXMVNE"; // flags, in order low to high, plus emu bit const string VALUES = "-?01"; StringBuilder sb = new StringBuilder(27); StatusFlags flags = WorkProps.EntryFlags; for (int i = 0; i < 9; i++) { // Want to show P reg flags (first 8) in conventional high-to-low order. int idx = (7 - i) + (i == 8 ? 9 : 0); int val = flags.GetBit((StatusFlags.FlagBits)idx); sb.Append(FLAGS[idx]); sb.Append(VALUES[val + 2]); sb.Append(' '); } currentFlagsLabel.Text = sb.ToString(); // // Project symbols tab // int symSelCount = projectSymbolsListView.SelectedIndices.Count; removeSymbolButton.Enabled = (symSelCount == 1); editSymbolButton.Enabled = (symSelCount == 1); // // Platform symbol files tab // int fileSelCount = symbolFilesListBox.SelectedIndices.Count; symbolFileRemoveButton.Enabled = (fileSelCount != 0); symbolFileUpButton.Enabled = (fileSelCount == 1 && symbolFilesListBox.SelectedIndices[0] != 0); symbolFileDownButton.Enabled = (fileSelCount == 1 && symbolFilesListBox.SelectedIndices[0] != symbolFilesListBox.Items.Count - 1); // // Extension Scripts tab // fileSelCount = extensionScriptsListBox.SelectedIndices.Count; extensionScriptRemoveButton.Enabled = (fileSelCount != 0); }
public void TAXInstruction(byte Instruction) { InstructionLength = 1; X_Register = A_Register; if (X_Register == 0) { Status_Register |= (StatusFlags)StatusFlags.Z; } if ((X_Register & (1 << 7 - 1)) != 0) { Status_Register |= (StatusFlags)StatusFlags.N; } Debug.WriteLine("TAX - Identifier byte: " + Instruction); }
public OpCode( byte hex, Operation operation, AddressMode addressMode, byte bytes, int cycles, StatusFlags affectsFlags) { Hex = hex; Operation = operation; AddressMode = addressMode; Bytes = bytes; Cycles = cycles; AffectsFlags = affectsFlags; }
public StatusFlags CheckStatus(string deviceid, int month) { StatusFlags objflags = new StatusFlags(); try { objflags.Response = alexaDBEntity.AlexaCheckTimeSheetStatus(deviceid, month).ToString(); } catch (Exception ex) { throw ex; } return(objflags); }
public void PowerUp() { //Set the initial value of CPU Registers. //Status = 0x24 (IRQ Disabled) //X, Y & A = 0x0 //SP = 0xFD //$4017 = 0 (Frame IRQ Disabled) //$4015 = 0 (Sound Channels Disabled) //$4000-$400F = 0 (Sound Registers) Status_Register = (StatusFlags)0x24; X_Register = 0x0; Y_Register = 0x0; A_Register = 0x0; SP_Register = 0xFD; }
public void CPXImmInstruction(byte Instruction) { InstructionLength = 4; byte Value = ROM.GetByte(PC_Register + 1); if (X_Register > Value) { Status_Register |= (StatusFlags)StatusFlags.C; } if (X_Register == Value) { Status_Register |= (StatusFlags)StatusFlags.Z; } Debug.WriteLine("CPX #" + Value + " - Identifier byte: " + Instruction); }
private void UpdateEntryFlags() { const string FLAGS = "CZIDXMVNE"; // flags, in order low to high, plus emu bit const string VALUES = "-?01"; StringBuilder sb = new StringBuilder(27); StatusFlags flags = mWorkProps.EntryFlags; for (int i = 0; i < 9; i++) { // Want to show P reg flags (first 8) in conventional high-to-low order. int idx = (7 - i) + (i == 8 ? 9 : 0); int val = flags.GetBit((StatusFlags.FlagBits)idx); sb.Append(FLAGS[idx]); sb.Append(VALUES[val + 2]); sb.Append(' '); } currentFlagsText.Text = sb.ToString(); }
private void RenderStatus(StatusFlags status) { if ((status & StatusFlags.Green) > 0) { Blit(new Rectangle(5, 0, 9, 6)); } if ((status & StatusFlags.Yellow) > 0) { Blit(new Rectangle(18, 0, 9, 6)); } if ((status & StatusFlags.Red) > 0) { Blit(new Rectangle(31, 0, 9, 6)); } if ((status & StatusFlags.Blue) > 0) { Blit(new Rectangle(44, 0, 9, 6)); } }
/// <summary> /// Creates an UndoableChange for a status flag override update. /// </summary> /// <param name="offset">Affected offset.</param> /// <param name="oldFlags">Current flags.</param> /// <param name="newFlags">New flags.</param> /// <returns></returns> public static UndoableChange CreateStatusFlagChange(int offset, StatusFlags oldFlags, StatusFlags newFlags) { if (oldFlags == newFlags) { Debug.WriteLine("No-op status flag change at " + offset); } UndoableChange uc = new UndoableChange(); uc.Type = ChangeType.SetStatusFlagOverride; uc.Offset = offset; uc.OldValue = oldFlags; uc.NewValue = newFlags; // This can affect instruction widths (for M/X) and conditional branches. We // don't need to re-analyze for changes to I/D, but users don't really need to // change those anyway, so it's not worth optimizing. uc.ReanalysisRequired = ReanalysisScope.CodeAndData; return(uc); }
public void Render(Core core, int chargeGoal, StatusFlags status, Color gridColor) { //Clear Graphics gfx = Graphics.FromImage(_bitmap); gfx.Clear(Color.Transparent); Rectangle r = new Rectangle(0, 0, _lowSrc.Width, _lowSrc.Height); Rectangle r2 = r; r2.Inflate(-2, -2); gfx.FillRectangle(new SolidBrush(gridColor), r2); gfx.DrawImage(_lowSrc, r, r, GraphicsUnit.Pixel); //Render Memory int i = 0; for (int y = 0; y < 16; y++) { for (int x = 0; x < 16; x++) { int data = core.Memory[i++]; _bitmap.SetPixel(5 + x * K, y * K + 7, Palette[(data & 0xF000) >> 12]); _bitmap.SetPixel(6 + x * K, y * K + 7, Palette[(data & 0xF00) >> 8]); _bitmap.SetPixel(5 + x * K, y * K + 8, Palette[(data & 0xF0) >> 4]); _bitmap.SetPixel(6 + x * K, y * K + 8, Palette[data & 0xF]); } } //Render Energy-Levels RenderVEnergyBar(core.Energy, 0); RenderVEnergyBar(core.Shield, 52); RenderHEnergyBar(core.Charge, chargeGoal, 53); //Render IP int px = 5 + K * (core.InstructionPointer % 16); int py = 7 + K * (core.InstructionPointer / 16); //Color instrColor = Palette[(core.Memory[core.InstructionPointer] & 0xF000) >> 12]; //Pen pen = new Pen(instrColor); Pen pen = new Pen(InstructionFrameColor); gfx.DrawRectangle(pen, new Rectangle(px - 1, py - 1, 3, 3)); //pen = new Pen(Color.FromArgb(32, Color.White)); //Graphics.FromImage(_bitmap).DrawRectangle(pen, new Rectangle(px - 2, py - 2, 5, 5)); RenderStatus(status); }
/// <summary> /// 공격자로부터 들어오는 신호에 따라 동작을 취함 /// </summary> public void GetConnection() { while (true) { Socket AccSock = Listener.Accept(); byte[] Flag = new byte[1]; AccSock.Receive(Flag); byte[] Respond = new byte[8]; if (Flag[0] == (int)SignalFlags.Check) { AccSock.Send(BitConverter.GetBytes((int)StatusFlag)); } else if (Flag[0] == (int)SignalFlags.Start) { byte[] Addrs = new byte[4]; AccSock.Receive(Addrs); RemoteIp = new IPAddress(Addrs); if (UseRandomPort) { IPGlobalProperties Properties = IPGlobalProperties.GetIPGlobalProperties(); TcpConnectionInformation[] AvailableEP = Properties.GetActiveTcpConnections(); Console.WriteLine(RemoteIp); List <int> UsedPorts = AvailableEP.Select(p => p.LocalEndPoint.Port).ToList(); foreach (int AvailablePort in UsedPorts) { if (!UsedPorts.Contains(AvailablePort)) { Console.WriteLine(AvailablePort); LocalEp = new IPEndPoint(LocalEp.Address, AvailablePort); AccSock.Send(BitConverter.GetBytes(AvailablePort)); LogSender("Available Port: " + AvailablePort); break; } } } LogSenderEP = new IPEndPoint(RemoteIp, LocalEp.Port - 1); StatusFlag = StatusFlags.Executing; AccSock.Send(BitConverter.GetBytes((int)StatusFlag)); GetPayload(); } } }
public void LDYImmInstruction(byte Instruction) { InstructionLength = 2; //Load value into Accumulator Register byte Value = ROM.GetByte(PC_Register + 1); Y_Register = Value; if (Y_Register == 0) { Status_Register |= (StatusFlags)StatusFlags.Z; } if ((Y_Register & (1 << 7 - 1)) != 0) { Status_Register |= (StatusFlags)StatusFlags.N; } Debug.WriteLine("LDY # " + Value + " - Identifier byte: " + Instruction); }
public void PeriodicCallback(ulong in_cpu_tick) { switch (m_operation_state) { // Type I operation (seek) case OperationState.Seek: if (m_tvcomputer.GetTicksSince(m_operation_start_tick) > m_pending_delay) { // operation delay time is expired m_fdc_status = m_pending_status; m_reg_hw_status = m_pending_hw_status; m_fdc_track = m_pending_track; m_disk_drives[m_current_drive_index].Track = m_pending_track; m_operation_state = OperationState.None; } break; } }
public void EORZePgInstruction(byte Instruction) { InstructionLength = 2; //Load value into Accumulator Register byte Value = ROM.GetByte(PC_Register + 1); A_Register = (byte)(A_Register ^ Value); if (A_Register == 0) { Status_Register |= (StatusFlags)StatusFlags.Z; } if ((A_Register & (1 << 7 - 1)) != 0) { Status_Register |= (StatusFlags)StatusFlags.N; } Debug.WriteLine("EOR #" + Value + " - Identifier byte: " + Instruction); }
public void PLAInstruction(byte Instruction) { InstructionLength = 1; //Load value into Accumulator Register byte Value = PullFromStack(); A_Register = Value; if (A_Register == 0) { Status_Register |= (StatusFlags)StatusFlags.Z; } if ((A_Register & (1 << 7 - 1)) != 0) { Status_Register |= (StatusFlags)StatusFlags.N; } Debug.WriteLine("PLA - Identifier byte: " + Instruction); }
public static I18NString Translate(StatusFlags statusFlags) { switch (statusFlags) { case StatusFlags.None: return(I18N.Instance.Get(null)); case StatusFlags.Slow: return(I18N.Instance.Get("enum_status_flag_slow")); case StatusFlags.Stun: return(I18N.Instance.Get("enum_status_flag_stun")); case StatusFlags.Swiftness: return(I18N.Instance.Get("enum_status_flag_swiftness")); case StatusFlags.Disarm: return(I18N.Instance.Get("enum_status_flag_disarm")); case StatusFlags.Silence: return(I18N.Instance.Get("enum_status_flag_silence")); case StatusFlags.Confusion: return(I18N.Instance.Get("enum_status_flag_confusion")); case StatusFlags.Weakness: return(I18N.Instance.Get("enum_status_flag_weakness")); case StatusFlags.Invisibility: return(I18N.Instance.Get("enum_status_flag_invisibility")); case StatusFlags.Immobilization: return(I18N.Instance.Get("enum_status_flag_immobilization")); case StatusFlags.Invulnerability: return(I18N.Instance.Get("enum_status_flag_invulnerability")); default: return(new I18NString(new I18NStringData(statusFlags.ToString()))); } }
public void ORAZIndrXInstruction(byte Instruction) { //TODO: Implement ORA (Zero Page, Indirect, X) InstructionLength = 2; //Load value into Accumulator Register byte Value = ROM.GetByte(PC_Register + 1); A_Register = (byte)(A_Register | Value); if (A_Register == 0) { Status_Register |= (StatusFlags)StatusFlags.Z; } if ((A_Register & (1 << 7 - 1)) != 0) { Status_Register |= (StatusFlags)StatusFlags.N; } Debug.WriteLine("EOR #" + Value + " - Identifier byte: " + Instruction); }
public void LdaZePgInstruction(byte Instruction) { InstructionLength = 2; //Put value in X Register in memory byte Address = ROM.GetByte(PC_Register + 1); byte Value = RAM.GetByte(Address); A_Register = Value; if (A_Register == 0) { Status_Register |= (StatusFlags)StatusFlags.Z; } if ((A_Register & (1 << 7 - 1)) != 0) { Status_Register |= (StatusFlags)StatusFlags.N; } Debug.WriteLine("LDA ZP $" + Address + " - Identifier byte: " + Instruction); }
/// <summary> /// 공격자로부터 연결이 들어올때까지 기다림 /// </summary> public void Wait() { Listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); foreach (IPAddress Addr in Dns.GetHostAddresses(Dns.GetHostName())) { if (Addr.AddressFamily == AddressFamily.InterNetwork) { LocalEp = new IPEndPoint(Addr, 19200); break; } } Console.WriteLine(LocalEp.Address); Listener.Bind(LocalEp); Listener.Listen(5); StatusFlag = StatusFlags.Listening; ThreadStart Ts = new ThreadStart(GetConnection); Thread thread = new Thread(Ts); thread.Start(); }
private void okButton_Click(object sender, EventArgs e) { StatusFlags flags = new StatusFlags(); flags.N = GetChecked(radioNDefault, radioNZero, radioNOne, radioNIndeterminate); flags.V = GetChecked(radioVDefault, radioVZero, radioVOne, radioVIndeterminate); flags.M = GetChecked(radioMDefault, radioMZero, radioMOne, radioMIndeterminate); flags.X = GetChecked(radioXDefault, radioXZero, radioXOne, radioXIndeterminate); flags.D = GetChecked(radioDDefault, radioDZero, radioDOne, radioDIndeterminate); flags.I = GetChecked(radioIDefault, radioIZero, radioIOne, radioIIndeterminate); flags.Z = GetChecked(radioZDefault, radioZZero, radioZOne, radioZIndeterminate); flags.C = GetChecked(radioCDefault, radioCZero, radioCOne, radioCIndeterminate); flags.E = GetChecked(radioEDefault, radioEZero, radioEOne, radioEIndeterminate); //// If they're setting emulation mode, also set M/X to 1. This is implicitly //// true, but things are a bit clearer if we make it explicit. //if (flags.E == 1) { // flags.M = flags.X = 1; //} FlagValue = flags; }
public Measurement(String meterPacket) { packet = meterPacket; if (meterPacket.Length != 12) { throw (new ArgumentException("incorrect format input string should be 12 char long")); } //convert range char to number range = (int)char.GetNumericValue(meterPacket[0]); var displayDigits = meterPacket.Substring(1, 5); SwitchPosition = (SwitchPositions)meterPacket[6]; status = (StatusFlags)(0x0f & meterPacket[7]); //colate all option flags into one enum options = (OptionsFlags)(0x0f & meterPacket[8]); options |= (OptionsFlags)((0x0f & meterPacket[9]) << 4); options |= (OptionsFlags)((0x0f & meterPacket[11]) << 12); options |= (OptionsFlags)((0x0f & meterPacket[10]) << 8); var measInfo = new UT61EMeter.UnitScaling(SwitchPosition, range, status, options); units = measInfo.units; if (!decimal.TryParse(displayDigits, out value)) { nonNumvalue = displayDigits; value = 99999; } else { nonNumvalue = null; value *= measInfo.valueMuntiplyer; } }
public void LdaAbsXInstruction(byte Instruction) { InstructionLength = 3; //Get value from Memory and put it in the A Register byte[] ByteData = { ROM.GetByte(PC_Register + 2), ROM.GetByte(PC_Register + 1) }; int MemoryAddress = BitConverter.ToUInt16(ByteData, 0); byte Value = RAM.GetByte(MemoryAddress + X_Register); A_Register = Value; if (A_Register == 0) { Status_Register |= (StatusFlags)StatusFlags.Z; } if ((A_Register & (1 << 7 - 1)) != 0) { Status_Register |= (StatusFlags)StatusFlags.N; } Debug.WriteLine("LDA $" + BitConverter.ToString(ByteData).Replace("-", string.Empty) + ", " + X_Register + "(" + MemoryAddress + X_Register + ")" + " - Identifier byte: " + Instruction); }
/// <summary> /// Fill a fixed buffer of LsTbd with /// </summary> private unsafe void CreateLsTbds( ParaProp pap, LsTbd *plsTbds, int lsTbdCount ) { for (int i = 0; i < lsTbdCount; i++) { TextTabProperties tab = (TextTabProperties)pap.Tabs[i]; plsTbds[i].lskt = Convert.LsKTabFromTabAlignment(tab.Alignment); plsTbds[i].ur = TextFormatterImp.RealToIdeal(tab.Location); if (tab.TabLeader != 0) { // Note: LS does not currently support surrogate character as tab leader and aligning character plsTbds[i].wchTabLeader = (char)tab.TabLeader; // tab leader requires state at display time for tab leader width fetching _statusFlags |= StatusFlags.KeepState; } plsTbds[i].wchCharTab = (char)tab.AligningCharacter; } }
private void _setStatusFlag(StatusFlags flag, bool setTrue) { if (setTrue) { _statusFlags |= flag; } else { _statusFlags &= ~flag; } }
private bool _getStatusFlag(StatusFlags flag) { return (_statusFlags & flag) != 0; }
public void Render(Core core, StatusFlags statusFlags) { if (_data != null && _buffer != null) { Graphics gfx = Graphics.FromImage(_buffer); int x, y; if(_data.Entries.Find(e => e.Core == core, out x, out y)) { _coreView.Render(core, _interpreter.GetNextInstructionCost(core), statusFlags, _data.Entries[y, x].Color); gfx.DrawImage(_coreView.Image, x * (_coreView.Width + _coreMargin), y * (_coreView.Height + _coreMargin)); } } Invalidate(); }
private unsafe void CreateLsTbds( ParaProp pap, LsTbd* plsTbds, int lsTbdCount ) { for (int i = 0; i < lsTbdCount; i++) { TextTabProperties tab = (TextTabProperties)pap.Tabs[i]; plsTbds[i].lskt = Convert.LsKTabFromTabAlignment(tab.Alignment); plsTbds[i].ur = TextFormatterImp.RealToIdeal(tab.Location); if (tab.TabLeader != 0) { // Note: LS does not currently support surrogate character as tab leader and aligning character plsTbds[i].wchTabLeader = (char)tab.TabLeader; // tab leader requires state at display time for tab leader width fetching _statusFlags |= StatusFlags.KeepState; } plsTbds[i].wchCharTab = (char)tab.AligningCharacter; } }
private void ReadBACData() { var BAC = (int)Util.Memory.ReadInt((int)Util.Memory.ReadInt(_BaseOffset + 0xB0) + 0x8); if (BAC != bac_off && BAC != 0) { //Gotta load BCM var tmpfile = File.Create(System.IO.Path.GetTempPath() + "/tmp.bac", 0x4000); var tmparr = Util.Memory.ReadAOB(BAC, 0xA0000); tmpfile.Write(tmparr, 0, tmparr.Length); tmpfile.Close(); bac = BACFile.FromFilename(System.IO.Path.GetTempPath() + "/tmp.bac", bcm); bac_off = BAC; } //Not in a match if (BAC == 0) return; var BAC_data = (int)Util.Memory.ReadInt(_BaseOffset + 0xB0); var XChange = X; X = Util.Memory.ReadFloat(_BaseOffset + 0x16D0); Y = Util.Memory.ReadFloat(_BaseOffset + 0x74); XChange = XChange - X; XVelocity = Util.Memory.ReadFloat(_BaseOffset + 0xe0); if (XVelocity == 0 && XChange != 0) { XVelocity = XChange; //Console.WriteLine("Using {0} for XVel due to XChange", XChange); } YVelocity = Util.Memory.ReadFloat(_BaseOffset + 0xe4); XAcceleration = Util.Memory.ReadFloat(_BaseOffset + 0x100); YAcceleration = Util.Memory.ReadFloat(_BaseOffset + 0x104); Meter = (int)Util.Memory.ReadShort(_BaseOffset + 0x6C3A); Revenge = (int)Util.Memory.ReadShort(_BaseOffset + 0x6C4E); Flags = (StatusFlags)Util.Memory.ReadInt(_BaseOffset + 0xBC); LastScriptIndex = ScriptIndex; ScriptIndex = (int)Util.Memory.ReadInt(BAC_data + 0x18); LastScriptName = ScriptName; var script = bac.Scripts.Where(x => x.Index == ScriptIndex).FirstOrDefault(); if (script == null) ScriptName = ScriptIndex.ToString(); else ScriptName = script.Name; if (ScriptName == "") return; ScriptTickTotal = Util.Memory.ReadInt(BAC_data + 0x24) / 0x10000; ScriptTickHitboxStart = Util.Memory.ReadInt(BAC_data + 0x28) / 0x10000; ScriptTickHitboxEnd = Util.Memory.ReadInt(BAC_data + 0x2C) / 0x10000; ScriptTickIASA = Util.Memory.ReadInt(BAC_data + 0x30) / 0x10000; ScriptTick = Util.Memory.ReadInt(BAC_data + 0x3C) / 0x10000; ScriptSpeed = Util.Memory.ReadInt(BAC_data + 0x18 + 0xC0) / 0x10000; if (ScriptTickIASA == 0) ScriptTickIASA = ScriptTickTotal; ComputeTickstoFrames(BAC); ComputeAttackData(BAC); if (ScriptFrameHitboxStart != 0) { if (ScriptFrame <= ScriptFrameHitboxStart) { State = CharState.Startup; StateTimer = ScriptFrameHitboxStart - ScriptFrame; } else if (ScriptFrame <= ScriptFrameHitboxEnd) { State = CharState.Active; StateTimer = ScriptFrameHitboxEnd - ScriptFrame; } else if (ScriptFrameIASA > 0 && ScriptFrame <= ScriptFrameIASA) { State = CharState.Recovery; StateTimer = ScriptFrameIASA - ScriptFrame; } else if (ScriptFrame <= ScriptFrameTotal) { State = CharState.Recovery; StateTimer = ScriptFrameTotal - ScriptFrame; } else { State = CharState.Neutral; } } else { State = CharState.Neutral; StateTimer = -1; AState = AttackState.None; } }
private void RenderStatus(StatusFlags status) { if ((status & StatusFlags.Green) > 0) Blit(new Rectangle(5, 0, 9, 6)); if ((status & StatusFlags.Yellow) > 0) Blit(new Rectangle(18, 0, 9, 6)); if ((status & StatusFlags.Red) > 0) Blit(new Rectangle(31, 0, 9, 6)); if ((status & StatusFlags.Blue) > 0) Blit(new Rectangle(44, 0, 9, 6)); }
private void DrawTextLine( DrawingContext drawingContext, Point origin, MatrixTransform antiInversion ) { Rect boundingBox = Rect.Empty; if (_ploline.Value != System.IntPtr.Zero) { TextFormatterContext context; LsErr lserr = LsErr.None; LSRECT rect = new LSRECT(0, 0, _metrics._textWidthAtTrailing, _metrics._height); // DrawingState needs to be properly disposed after performing actual drawing operations. using (DrawingState drawingState = new DrawingState(drawingContext, origin, antiInversion, this)) { context = _metrics._formatter.AcquireContext( drawingState, _ploc.Value ); // set the collector and send the line to LS to draw context.EmptyBoundingBox(); // LS line reference origin LSPOINT lsRefOrigin = new LSPOINT(0, _metrics._baselineOffset); lserr = UnsafeNativeMethods.LoDisplayLine( _ploline.Value, ref lsRefOrigin, 1, // 0 - opaque, 1 - transparent ref rect ); } boundingBox = context.BoundingBox; // get the exception in context before it is released Exception callbackException = context.CallbackException; context.Release(); if(lserr != LsErr.None) { if(callbackException != null) { // rethrow exception thrown in callbacks throw callbackException; } else { // throw with LS error codes TextFormatterContext.ThrowExceptionFromLsError(SR.Get(SRID.CreateLineFailure, lserr), lserr); } } // keep context alive at least til here GC.KeepAlive(context); } if (_collapsingSymbol != null) { // draw collapsing symbol if any Point vectorToOrigin = new Point(); if (antiInversion != null) { vectorToOrigin = origin; origin.X = origin.Y = 0; } boundingBox.Union(DrawCollapsingSymbol(drawingContext, origin, vectorToOrigin)); } BuildOverhang(origin, boundingBox); _statusFlags |= StatusFlags.BoundingBoxComputed; }
private void FormatLine( FullTextState fullText, int cpFirst, int lineLength, int formatWidth, int finiteFormatWidth, int paragraphWidth, LineFlags lineFlags, FormattedTextSymbols collapsingSymbol ) { _metrics._formatter = fullText.Formatter; Debug.Assert(_metrics._formatter != null); TextStore store = fullText.TextStore; TextStore markerStore = fullText.TextMarkerStore; FormatSettings settings = store.Settings; ParaProp pap = settings.Pap; _paragraphTextDecorations = pap.TextDecorations; if (_paragraphTextDecorations != null) { if (_paragraphTextDecorations.Count != 0) { _defaultTextDecorationsBrush = pap.DefaultTextDecorationsBrush; } else { _paragraphTextDecorations = null; } } // acquiring LS context TextFormatterContext context = _metrics._formatter.AcquireContext(fullText, IntPtr.Zero); LsLInfo plslineInfo = new LsLInfo(); LsLineWidths lineWidths = new LsLineWidths(); fullText.SetTabs(context); int lscpLineLength = 0; // line length in LSCP if (lineLength > 0) { // line length is previously known (e.g. during optimal paragraph formatting), // prefetch lsruns up to the specified line length. lscpLineLength = PrefetchLSRuns(store, cpFirst, lineLength); } IntPtr ploline; LsErr lserr = context.CreateLine( cpFirst, lscpLineLength, formatWidth, lineFlags, IntPtr.Zero, // single-line formatting does not require break record out ploline, out plslineInfo, out _depthQueryMax, out lineWidths ); // Did we exceed the LineServices maximum line width? if (lserr == LsErr.TooLongParagraph) { // Determine where to insert a fake line break. FullTextState.CpMeasured // is a reasonable estimate since we know the nominal widths up to that // point fit within the margin. int cpLimit = fullText.CpMeasured; int subtract = 1; for (;;) { // The line must contain at least one character position. if (cpLimit < 1) { cpLimit = 1; } store.InsertFakeLineBreak(cpLimit); lserr = context.CreateLine( cpFirst, lscpLineLength, formatWidth, lineFlags, IntPtr.Zero, // single-line formatting does not require break record out ploline, out plslineInfo, out _depthQueryMax, out lineWidths ); if (lserr != LsErr.TooLongParagraph || cpLimit == 1) { // We're done or can't chop off any more text. break; } else { // Chop off more text and try again. Double the amount of // text we chop off each time so we retry too many times. cpLimit = fullText.CpMeasured - subtract; subtract *= 2; } } } _ploline.Value = ploline; // get the exception in context before it is released Exception callbackException = context.CallbackException; // release the context context.Release(); if(lserr != LsErr.None) { GC.SuppressFinalize(this); if(callbackException != null) { // rethrow exception thrown in callbacks throw WrapException(callbackException); } else { // throw with LS error codes TextFormatterContext.ThrowExceptionFromLsError(SR.Get(SRID.CreateLineFailure, lserr), lserr); } } // keep context alive at least till here GC.KeepAlive(context); unsafe { // construct text metrics for the line _metrics.Compute( fullText, cpFirst, paragraphWidth, collapsingSymbol, ref lineWidths, &plslineInfo ); } // keep record for min width as we may be formatting min/max _textMinWidthAtTrailing = lineWidths.upMinStartTrailing - _metrics._textStart; if (collapsingSymbol != null) { _collapsingSymbol = collapsingSymbol; _textMinWidthAtTrailing += TextFormatterImp.RealToIdeal(collapsingSymbol.Width); } else { // overflow detection for potential collapsible line if (_metrics._textStart + _metrics._textWidthAtTrailing > finiteFormatWidth) { bool hasOverflowed = true; if (_textFormattingMode == TextFormattingMode.Display) { // apply display-mode rounding before checking for overflow double realWidth = Width; double realFormatWidth = _metrics._formatter.IdealToReal(finiteFormatWidth); hasOverflowed = (TextFormatterImp.CompareReal(realWidth, realFormatWidth, _textFormattingMode) > 0); } if (hasOverflowed) { // line has overflowed _statusFlags |= StatusFlags.HasOverflowed; // let's keep the full text state around. We'll need it later for collapsing _fullText = fullText; } } } if ( fullText != null && ( fullText.KeepState || (_statusFlags & StatusFlags.KeepState) != 0 ) ) { // the state of full text is to be kept after formatting is done _fullText = fullText; } // retain all line properties for interactive operations _ploc = context.Ploc; _cpFirst = cpFirst; _paragraphWidth = paragraphWidth; if (pap.RightToLeft) _statusFlags |= StatusFlags.RightToLeft; if (plslineInfo.fForcedBreak != 0) _statusFlags |= StatusFlags.IsTruncated; // retain the state of plsruns _plsrunVector = store.PlsrunVector; _lsrunsMainText = store.LsrunList; if (markerStore != null) _lsrunsMarkerText = markerStore.LsrunList; // we store the text source in the line in case drawing code calls // the TextSource to find out the text effect index. // _textSource = settings.TextSource; }
private FullTextLine(TextFormattingMode textFormattingMode, bool justify) { _textFormattingMode = textFormattingMode; if (justify) { _statusFlags |= StatusFlags.IsJustified; } _metrics = new TextMetrics(); _ploline = new SecurityCriticalDataForSet<IntPtr>(IntPtr.Zero); }
/// <summary> /// Constructing a FullTextLine /// </summary> /// <param name="settings">text formatting settings</param> /// <param name="cpFirst">Line's first cp</param> /// <param name="lineLength">character length of the line</param> /// <param name="paragraphWidth">paragraph width</param> /// <param name="lineFlags">line formatting control flags</param> internal FullTextLine( FormatSettings settings, int cpFirst, int lineLength, int paragraphWidth, LineFlags lineFlags ) : this(settings.TextFormattingMode, settings.Pap.Justify) { if ( (lineFlags & LineFlags.KeepState) != 0 || settings.Pap.AlwaysCollapsible) { _statusFlags |= StatusFlags.KeepState; } int finiteFormatWidth = settings.GetFiniteFormatWidth(paragraphWidth); FullTextState fullText = FullTextState.Create(settings, cpFirst, finiteFormatWidth); // formatting the line FormatLine( fullText, cpFirst, lineLength, fullText.FormatWidth, finiteFormatWidth, paragraphWidth, lineFlags, null // collapsingSymbol ); }
/// <summary> /// Draw a simple text line /// </summary> /// <returns>a drawing bounding box</returns> private void DrawTextLine( DrawingContext drawingContext, Point origin ) { if (_runs.Length <= 0) { _boundingBox = Rect.Empty; _statusFlags |= StatusFlags.BoundingBoxComputed; return; } int idealXRelativeToOrigin = _idealOffsetUnRounded; double y = origin.Y + Baseline; if (drawingContext != null) { drawingContext.PushGuidelineY1(y); } Rect boundingBox = Rect.Empty; try { foreach (SimpleRun run in _runs) { boundingBox.Union( run.Draw( drawingContext, _settings.Formatter.IdealToReal(idealXRelativeToOrigin) + origin.X, y, false ) ); idealXRelativeToOrigin += run.IdealWidth; } } finally { if (drawingContext != null) { drawingContext.Pop(); } } if(boundingBox.IsEmpty) { boundingBox = new Rect(Start, 0, 0, 0); } else { boundingBox.X -= origin.X; boundingBox.Y -= origin.Y; } _boundingBox = boundingBox; _statusFlags |= StatusFlags.BoundingBoxComputed; }
protected override void ParseBody() { this.Body.Position = 0; var protocolVersion = this.Body.ReadByte(); this.ServerVersion = this.Body.ReadNulTerminatedString(); this.ConnectionId = this.Body.ReadInt(); this.AuthPluginDataPart1 = this.Body.ReadFixedBytes(8); this.Body.Position += 1; this.Capabilities = (CapabilityFlags)this.Body.ReadShort(); this.CharacterSet = (CharacterSet)this.Body.ReadByte(); this.Status = (StatusFlags)this.Body.ReadShort(); this.Capabilities |= (CapabilityFlags)(this.Body.ReadShort() << 16); this.AuthPluginDataLength = (byte)this.Body.ReadByte(); this.Body.Position += 10; if ((Capabilities & CapabilityFlags.CLIENT_SECURE_CONNECTION) > 0) { var length = Math.Max(13, this.AuthPluginDataLength - 8) - 1; this.AuthPluginDataPart2 = this.Body.ReadFixedBytes(length); this.Body.Position += 1; } if ((Capabilities & CapabilityFlags.CLIENT_PLUGIN_AUTH) > 0) { this.AuthPluginName = this.Body.ReadNulTerminatedString(); } }
/// <summary> /// Create Get Log state reply object /// </summary> /// <param name="reply">Raw 9 or 21-bit Get Log State reply</param> public LogState(byte[] reply) { if (!((9 == reply.Length) || (20 == reply.Length))) { throw new ArgumentOutOfRangeException("GetLogState replies must be 9 or 20 bytes in length"); } int offset = 0; _LimitCount = new LimitCounter(reply, offset); offset += 4; _SystemStat = new SystemStatus(reply, offset); offset += 4; if (20 == reply.Length) { _SetShelLifeBlock0 = new ShelfLifeBlock0(reply, offset); offset += 4; _SetShelLifeBlock1 = new ShelfLifeBlock1(reply, offset); offset += 4; _remainingShelfLife = GetRemainingShelfLife(reply, offset); offset += 3; } _StatFlags = new StatusFlags(reply[offset]); offset += 1; }
public void Render(Core core, int chargeGoal, StatusFlags status, Color gridColor) { //Clear Graphics gfx = Graphics.FromImage(_bitmap); gfx.Clear(Color.Transparent); Rectangle r = new Rectangle(0, 0, _lowSrc.Width, _lowSrc.Height); Rectangle r2 = r; r2.Inflate(-2, -2); gfx.FillRectangle(new SolidBrush(gridColor), r2); gfx.DrawImage(_lowSrc, r, r, GraphicsUnit.Pixel); //Render Memory int i = 0; for (int y = 0; y < 16; y++) for (int x = 0; x < 16; x++) { int data = core.Memory[i++]; _bitmap.SetPixel(5 + x * K, y * K + 7, Palette[(data & 0xF000) >> 12]); _bitmap.SetPixel(6 + x * K, y * K + 7, Palette[(data & 0xF00) >> 8]); _bitmap.SetPixel(5 + x * K, y * K + 8, Palette[(data & 0xF0) >> 4]); _bitmap.SetPixel(6 + x * K, y * K + 8, Palette[data & 0xF]); } //Render Energy-Levels RenderVEnergyBar(core.Energy, 0); RenderVEnergyBar(core.Shield, 52); RenderHEnergyBar(core.Charge, chargeGoal, 53); //Render IP int px = 5 + K * (core.InstructionPointer % 16); int py = 7 + K * (core.InstructionPointer / 16); //Color instrColor = Palette[(core.Memory[core.InstructionPointer] & 0xF000) >> 12]; //Pen pen = new Pen(instrColor); Pen pen = new Pen(InstructionFrameColor); gfx.DrawRectangle(pen, new Rectangle(px - 1, py - 1, 3, 3)); //pen = new Pen(Color.FromArgb(32, Color.White)); //Graphics.FromImage(_bitmap).DrawRectangle(pen, new Rectangle(px - 2, py - 2, 5, 5)); RenderStatus(status); }
/// <summary> /// Constructor /// </summary> public NullTTSEngine() { _currentStatus = StatusFlags.None; EvtVoiceChanged = null; EvtStatusChanged = null; }
/// <summary> /// Initializes a new instance of the TTSStatusChangedEventArgs class /// </summary> /// <param name="flags"></param> public TTSStatusChangedEventArgs(StatusFlags flags) { Status = flags; }
/// <summary> /// Constructing a lightweight text line /// </summary> /// <param name="settings">text formatting settings</param> /// <param name="cpFirst">line first cp</param> /// <param name="paragraphWidth">paragraph width</param> /// <param name="runs">collection of simple runs</param> /// <param name="trailing">line trailing spaces</param> /// <param name="trailingSpaceWidth">line trailing spaces width</param> /// <Remarks> /// SimpleTextLine is constructed with Ideal width such that the line breaking /// behavior is consistent with the FullTextLine /// </Remarks> public SimpleTextLine( FormatSettings settings, int cpFirst, int paragraphWidth, ArrayList runs, ref int trailing, ref int trailingSpaceWidth ) { // Compute line metrics int count = 0; _settings = settings; double realAscent = 0; double realDescent = 0; double realHeight = 0; ParaProp pap = settings.Pap; TextFormatterImp formatter = settings.Formatter; int idealWidth = 0; while(count < runs.Count) { SimpleRun run = (SimpleRun)runs[count]; if(run.Length > 0) { if(run.EOT) { // EOT run has no effect on height, it is part of trailing spaces trailing += run.Length; _cpLengthEOT += run.Length; } else { realHeight = Math.Max(realHeight, run.Height); realAscent = Math.Max(realAscent, run.Baseline); realDescent = Math.Max(realDescent, run.Height - run.Baseline); } _cpLength += run.Length; idealWidth += run.IdealWidth; } count++; } // Roundtrip run baseline and height to take its precision back to the specified formatting resolution. // // We have to do this to guarantee sameness of line alignment metrics produced by fast and full path. // This is critical for TextBlock/TextFlow. They rely on the fact that line created during Measure must // yield the same metrics as one created during Render, while there is no guarantee that the paragraph // properties of that same line remains the same in both timings e.g. Measure may not specify // justification (which results in us formatting the line in fast path), while Render might // (which results in us formatting that same line in full path). _baselineOffset = formatter.IdealToReal(TextFormatterImp.RealToIdeal(realAscent)); if (realAscent + realDescent == realHeight) { _height = formatter.IdealToReal(TextFormatterImp.RealToIdeal(realHeight)); } else { _height = formatter.IdealToReal(TextFormatterImp.RealToIdeal(realAscent) + TextFormatterImp.RealToIdeal(realDescent)); } if(_height <= 0) { // line is empty (containing only EOP) // we need to work out the line height // It needs to be exactly the same as in full path. _height = formatter.IdealToReal((int)Math.Round(pap.DefaultTypeface.LineSpacing(pap.EmSize, Constants.DefaultIdealToReal, Util.PixelsPerDip, _settings.TextFormattingMode))); _baselineOffset = formatter.IdealToReal((int)Math.Round(pap.DefaultTypeface.Baseline(pap.EmSize, Constants.DefaultIdealToReal, Util.PixelsPerDip, _settings.TextFormattingMode))); } // Initialize the array of runs and set the TrimTrailingUnderline flag // for runs that contain trailing spaces at the end of the line. _runs = new SimpleRun[count]; for(int i = count - 1, t = trailing; i >= 0; --i) { SimpleRun run = (SimpleRun)runs[i]; if (t > 0) { run.TrimTrailingUnderline = true; t -= run.Length; } _runs[i] = run; } _cpFirst = cpFirst; _trailing = trailing; int idealWidthAtTrailing = idealWidth - trailingSpaceWidth; if(pap.Align != TextAlignment.Left) { switch(pap.Align) { case TextAlignment.Right: _idealOffsetUnRounded = paragraphWidth - idealWidthAtTrailing; _offset = formatter.IdealToReal(_idealOffsetUnRounded); break; case TextAlignment.Center: // exactly consistent with FullTextLine _idealOffsetUnRounded = (int)Math.Round((paragraphWidth - idealWidthAtTrailing) * 0.5); _offset = formatter.IdealToReal(_idealOffsetUnRounded); break; } } // converting all the ideal values to real values _width = formatter.IdealToReal(idealWidth); _widthAtTrailing = formatter.IdealToReal(idealWidthAtTrailing); _paragraphWidth = formatter.IdealToReal(paragraphWidth); // paragraphWidth == 0 means format width is unlimited and hence not overflowable. // we keep paragraphWidth for alignment calculation if (paragraphWidth > 0 && _widthAtTrailing > _paragraphWidth) { _statusFlags |= StatusFlags.HasOverflowed; } }