public void OnNext(string value) { var parsedLine = DolphinMbpWriteLine.ParseString(value); if (parsedLine?.WriteSize == 32) { uint chunkOffset = (parsedLine.MemoryAddr - BITS_BASE_ADDRESS) / 4; // If the memory address is less than the flags base address, flagNum will overflow // so we only need to check flagNum < FLAGS_SIZE if (chunkOffset >= BITS_CHUNKS_COUNT) { return; } uint oldChunk = cachedBitChunks[chunkOffset]; uint newChunk = parsedLine.Value; cachedBitChunks[chunkOffset] = newChunk; List <int> changedBits = BitUtils.GetListOfBits((int)(oldChunk ^ newChunk)); var eventArgs = new SoALBitChangedEventArgs { ChunkNumber = (int)chunkOffset }; foreach (int b in changedBits) { eventArgs.ChunkBit = b; eventArgs.IsBeingSet = (newChunk & (1 << b)) != 0; OnChange?.Invoke(this, eventArgs); } } }
private static void LogBitChange(TextWriter writer, SoALBitChangedEventArgs arg) { writer.WriteLine("Bit #{0:d5} was {1}.\t\t(Chunk: {2}, Bit: {3})", arg.BitNumber, arg.IsBeingSet ? "set" : "cleared", arg.ChunkNumber, arg.ChunkBit); }