protected override void InternalExecute(CpuState cpuState, IMemory memory, byte arg, Action<byte> write, ref int cycles) { var res = (byte)((cpuState.X - 1) & 0xFF); cpuState.X = res; cpuState.SetNegativeFlag(res); cpuState.SetZeroFlag(res); }
public CPU() { mem = new MemoryBasic(); mem.Init(Config.MEM_SIZE); registerSet = new RegisterSet(); }
public int Execute(CpuState cpuState, IMemory memory) { // Addresses are relative to the beginning of the next instruction not // the beginning of this one, so we'll need to advance the program counter. cpuState.Pc += 2; if (ShouldBranch(cpuState, memory)) { var offset = memory[cpuState.Pc - 1]; ushort newPc; if ((offset & 0x80) != 0) { newPc = (ushort) (cpuState.Pc - (0x100 - offset)); } else { newPc = (ushort)(cpuState.Pc + offset); } int cycles = 3; if ((newPc & 0xFF00) != (cpuState.Pc & 0xFF00)) { // Extra cycle if the relative branch occurs to cross a page boundary ++cycles; } cpuState.Pc = newPc; return cycles; } return 2; }
public Patch(IMemory memory, IntPtr targetAddress, byte[] replaceWith) { _protector = new MemoryPageProtector(new Win32Implementation(), targetAddress, (IntPtr)replaceWith.Length); _memory = memory; TargetAddress = targetAddress; _replaceWith = replaceWith; }
public DBExit(IAOF _AOF, IMemory _Memory) { AOF = _AOF; Memory = _Memory; exit(); }
protected override void InternalExecute(CpuState cpuState, IMemory memory, byte arg, Action<byte> write, ref int cycles) { bool carry = cpuState.IsFlagSet(CpuState.Flags.Carry); cpuState.SetFlag(CpuState.Flags.Carry, arg & 0x80); arg <<= 1; if (carry) { arg |= 1; } write(arg); cpuState.SetNegativeFlag(arg); cpuState.SetZeroFlag(arg); switch (Variants[memory[cpuState.Pc]]) { case AddressingMode.Accumulator: cycles = 2; break; case AddressingMode.ZeroPage: cycles = 5; break; case AddressingMode.ZeroPageXIndexed: cycles = 6; break; case AddressingMode.Absolute: cycles = 6; break; case AddressingMode.AbsoluteX: cycles = 7; break; } }
public unsafe Int3Hook(IMemory memory, IntPtr targetAddress, IntPtr hookAddress) : base(memory, targetAddress, new[] { (byte)OpCode.Int3 }) { _hookAddress = hookAddress; _notToBeGCed = VectoredHandler; _handler = AddVectoredExceptionHandler(0, _notToBeGCed); }
public PpuMap(IMemory ram, IMemory chr, VRAMLayout layout) { m_ram = ram; m_chr = chr; m_palette = new Ram(0xFF); m_layout = layout; }
public static string DumpAsText(IMemory memory) { var dumpStringBuilder = new StringBuilder(299320); dumpStringBuilder.AppendLine(" 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 0123456789ABCDEF"); var ip = 0; while (ip < memory.Size) { int rowStartPointer = ip; dumpStringBuilder.Append(ip.ToString("X4")); dumpStringBuilder.Append(" "); for (int columnIndex = 0; columnIndex < 0x10; columnIndex++) { dumpStringBuilder.Append(memory.Raw[rowStartPointer].ToString("X2")); dumpStringBuilder.Append(' '); rowStartPointer++; } dumpStringBuilder.Append(' '); rowStartPointer = ip; for (int columnIndex = 0; columnIndex < 0x10; columnIndex++) { dumpStringBuilder.Append(_codePageMap[memory.Raw[rowStartPointer]]); rowStartPointer++; } ip += 0x10; dumpStringBuilder.AppendLine(); } return dumpStringBuilder.ToString(); }
public int Execute(CpuState cpuState, IMemory memory) { throw new Exception("die"); cpuState.Interrupt(0xFFFE, memory); return 7; }
protected override void InternalExecute(CpuState cpuState, IMemory memory, byte arg, Action<byte> write, ref int cycles) { cpuState.A = cpuState.PopStack(memory); cpuState.SetNegativeFlag(cpuState.A); cpuState.SetZeroFlag(cpuState.A); cycles = 4; }
protected override void InternalExecute(CpuState cpuState, IMemory memory, byte arg, Action<byte> write, ref int cycles) { ushort result = arg; result <<= 1; var byteResult = (byte) (result & 0xFF); write(byteResult); cpuState.SetNegativeFlag(byteResult); cpuState.SetZeroFlag(byteResult); cpuState.SetFlag(CpuState.Flags.Carry, result & 0xFF00); switch (Variants[memory[cpuState.Pc]]) { case AddressingMode.Accumulator: cycles = 2; break; case AddressingMode.ZeroPage: cycles = 5; break; case AddressingMode.ZeroPageXIndexed: cycles = 6; break; case AddressingMode.Absolute: cycles = 6; break; case AddressingMode.AbsoluteX: cycles = 7; break; } }
protected override void InternalExecute(CpuState cpuState, IMemory memory, byte arg, ref int cycles) { cpuState.X = arg; cpuState.SetNegativeFlag(arg); cpuState.SetZeroFlag(arg); }
public Cpu(IMemory memory, IInput input, IOutput output) { _memory = memory; In = input; Out = output; Registers = new byte[16]; Commands = new Dictionary<byte, Command> { {0x01, new IncCommand(this)}, {0x02, new DecCommand(this)}, {0x03, new MovCommand(this)}, {0x04, new MovcCommand(this)}, {0x05, new LslCommand(this)}, {0x06, new LsrCommand(this)}, {0x07, new JmpCommand(this)}, {0x0A, new JfeCommand(this)}, {0x0B, new RetCommand(this)}, {0x0C, new AddCommand(this)}, {0x0D, new SubCommand(this)}, {0x0E, new XorCommand(this)}, {0x0F, new OrCommand(this)}, {0x10, new InCommand(this)}, {0x11, new OutCommand(this)} }; }
public Alu(IMemory memory, IRegisterFile registerFile, ICpuStack cpuStack, ILookupTables lookupTables) { _memory = memory; _lookupTables = lookupTables; _registerFile = registerFile; _cpuStack = cpuStack; }
public int Execute(CpuState cpuState, IMemory memory) { var ret = cpuState.Pc + 2; cpuState.PushStack((byte)((ret & 0xFF00) >> 8), memory); cpuState.PushStack((byte) (ret & 0xFF), memory); cpuState.Pc = memory.ReadShort(cpuState.Pc + 1); return 6; }
public Module( Kernel kernel ) { Debug.Assert( kernel != null ); _kernel = kernel; _memory = _kernel.Memory; _memorySystem = _kernel.MemorySystem; }
void before_each() { buffer = Marshal.AllocHGlobal(4); replaceWith = new byte[] { 0x37, 0x13, 0, 0 }; Marshal.WriteInt32(buffer, 0); memory = new InProcessMemory(); patch = new Patch(memory, buffer, replaceWith); }
protected override void InternalExecute(CpuState cpuState, IMemory memory, byte arg, Action<byte> write, ref int cycles) { var breakSet = cpuState.IsFlagSet(CpuState.Flags.Break); cpuState.StatusRegister = cpuState.PopStack(memory); cpuState.StatusRegister |= 1 << 5; cpuState.SetFlag(CpuState.Flags.Break, breakSet); cycles = 4; }
public void Interrupt(int interruptAddress, IMemory mem) { PushStack((byte)(Pc >> 8), mem); PushStack((byte)(Pc & 0xFF), mem); PushStack(StatusRegister, mem); SetFlag(Flags.InterruptDisable, true); Pc = mem.ReadShort(interruptAddress); }
public void Setup() { _memory = Substitute.For<IMemory>(); _input = Substitute.For<IInput>(); _output = Substitute.For<IOutput>(); _cpu = new Cpu(_memory, _input, _output); }
/// <summary> /// Initializes a new instance of the <see cref="FrameBuffer32bpp"/> class. /// </summary> /// <param name="memory">The memory.</param> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <param name="offset">The offset.</param> /// <param name="depth">The depth.</param> public FrameBuffer32bpp(IMemory memory, uint width, uint height, uint offset, uint depth) { this.memory = memory; this.width = width; this.height = height; this.offset = offset; this.depth = depth; }
/// <summary> /// Initializes a new instance of the <see cref="FrameBuffer8bpp"/> class. /// </summary> /// <param name="memory">The memory.</param> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <param name="offset">The offset.</param> /// <param name="bytesPerLine">The bytes per line.</param> public FrameBuffer8bpp(IMemory memory, uint width, uint height, uint offset, uint bytesPerLine) { this.memory = memory; this.width = width; this.height = height; this.offset = offset; this.bytesPerLine = bytesPerLine; }
public int Execute(CpuState cpuState, IMemory memory) { var low = cpuState.PopStack(memory); var high = cpuState.PopStack(memory); cpuState.Pc = (ushort)((high << 8) | low); ++cpuState.Pc; return 6; }
protected override void InternalExecute(CpuState cpuState, IMemory memory, byte arg, Action<byte> write, ref int cycles) { var comparer = cpuState.A; var cmp = comparer - arg; cpuState.SetFlag(CpuState.Flags.Carry, cmp >= 0); cpuState.SetNegativeFlag((byte) (cmp & 0xFF)); cpuState.SetZeroFlag((byte) (cmp & 0xFF)); }
/// <summary> /// Create new system based on Z80 /// </summary> /// <param name="memory">System memory</param> /// <param name="io">IO</param> /// <param name="cpuStack"></param> /// <param name="lookupTables"></param> /// <param name="executionUnit"></param> /// <param name="registerFile"></param> public ZilogZ80Cpu(IMemory memory, IInputOutputDevice io, ICpuStack cpuStack, ILookupTables lookupTables, IExecutionUnit executionUnit, IRegisterFile registerFile) { _memory = memory; _io = io; _executionUnit = executionUnit; _registerFile = registerFile; _cpuStack = cpuStack; lookupTables.Init(); Reset(); }
public ExecutionUnit(IMemory memory, IRegisterFile registerFile, ICpuStack cpuStack, IAlu alu, IInputOutputDevice outputDevice, ILookupTables lookupTables) { _memory = memory; _registerFile = registerFile; _cpuStack = cpuStack; _alu = alu; _inputOutputDevice = outputDevice; _lookupTables = lookupTables; }
public BasicCpu(IMemory memory, ICpuInstructionExecutor instructionExector) { SetupRegisters(); _memory = memory; _instructionExector = instructionExector; _instructionExector.Cpu = this; _interruptTable = new Dictionary<byte, Action>(); }
public void OpenFile(string path, IMemory memory) { try { ValidationAndParsing(path).FillMemory(memory); } catch(Exception ex) { throw ex; } }
public HexFileViewModel(IMemory memory, string path, HexFileManagerViewModel hexFileManagerViewModel) { this.hexFileManagerViewModel = hexFileManagerViewModel; memoryViewModel = new MemoryViewModel(memory); this.memory = memory; this.path = path; fileName = System.IO.Path.GetFileName(path); isDirty = false; SaveCommand = new DelegateCommand<object>(OnSave, CanSave); CloseCommand = new DelegateCommand<object>(OnClose, CanClose); Debug.WriteLine(string.Format("Open File: {0}", path)); }
public PageManager(IMemory memory) => m_Memory = memory;
/// <summary> /// Initializes a new instance of the <see cref="CustomizedMemory"/> class. /// </summary> /// <param name="globalMemory">Global memory.</param> /// <param name="localMemory">Local memory.</param> public CustomizedMemory(IMemory globalMemory, IMemory localMemory = null) { this.GlobalMemory = globalMemory; this.LocalMemory = localMemory; }
public StringPointer(IMemory memory, MemoryAddress value) : this(memory, value, 512) { }
public void SetValue <T>(IMemoryOffset <T> offset, T value) { using IMemory <T> mem = this.GetMemory(offset); mem.Value = value; }
public ACreepBase(string id, IJsInterop js) : base(id, js) { store = new Store($"Game.creeps.{name}.store", js); memory = new Memory($"Memory.creeps.{name}", js); }
public AtlasRegions(IMemory mem, Func <long> address) : base(mem, address) { }
/// <summary> /// Initializes a new instance of the <see cref="PatchManager" /> class. /// </summary> /// <param name="processMemory">The process memory.</param> public PatchManager(IMemory processMemory) { MemoryBase = processMemory; }
protected abstract IHook CreateHook(IMemory memory, IntPtr targetAddress, IntPtr hookAddress);
public OpCode32Id04(IMemory memory, IRegister register, ISystemNotifier environment) : base(memory, register) { this.environment = environment; // memry and register are stored in the base class }
private static (object value, string error) Evaluator(Expression expression, IMemory state, Options options) { TimexProperty parsed = null; string result = null; string error = null; var(validYear, validMonth, validDay) = (0, 0, 0); var currentUtcTime = DateTime.UtcNow; var convertedDateTime = currentUtcTime; IReadOnlyList <object> args; (args, error) = FunctionUtils.EvaluateChildren(expression, state, options); if (error == null) { (parsed, error) = FunctionUtils.ParseTimexProperty(args[0]); } if (error == null) { if (parsed.Year != null || parsed.Month == null || parsed.DayOfMonth == null) { error = $"{args[0]} must be a timex string which only contains month and day-of-month, for example: 'XXXX-10-31'."; } } if (error == null) { if (args.Count == 2 && args[1] is string timezone) { object convertedTimeZone = null; (convertedTimeZone, error) = FunctionUtils.ConvertTimeZoneFormat(timezone); if (error == null) { convertedDateTime = TimeZoneInfo.ConvertTimeFromUtc(currentUtcTime, (TimeZoneInfo)convertedTimeZone); } } else { convertedDateTime = currentUtcTime.ToLocalTime(); } } if (error == null) { var(year, month, day) = (convertedDateTime.Year, convertedDateTime.Month, convertedDateTime.Day); if (parsed.Month > month || (parsed.Month == month && parsed.DayOfMonth >= day)) { validYear = year; } else { validYear = year + 1; } validMonth = parsed.Month ?? 0; validDay = parsed.DayOfMonth ?? 0; if (validMonth == 2 && validDay == 29) { while (!DateTime.IsLeapYear(validYear)) { validYear += 1; } } result = TimexProperty.FromDate(new DateTime(validYear, validMonth, validDay)).TimexValue; } return(result, error); }
public Saver() { this.memory = new Memory <T>(); }
public void AssignMemory(IMemory memory) { this.memory = memory; }
public MemoryParameter(IMemory memory, int stackSize) { Memory = memory; StackSize = stackSize; }
/// <summary> /// Starts the device. /// </summary> /// <param name="deviceDriver">The device driver.</param> static public void StartDevice(Mosa.DeviceSystem.DeviceDriver deviceDriver) { var driverAtttribute = deviceDriver.Attribute as ISADeviceDriverAttribute; // Don't load the VGAText and PIC drivers if (driverAtttribute.BasePort == 0x03B0 || driverAtttribute.BasePort == 0x20) { return; } if (driverAtttribute.AutoLoad) { var hardwareDevice = System.Activator.CreateInstance(deviceDriver.DriverType) as IHardwareDevice; var ioPortRegions = new LinkedList <IIOPortRegion>(); var memoryRegions = new LinkedList <IMemoryRegion>(); ioPortRegions.AddLast(new IOPortRegion(driverAtttribute.BasePort, driverAtttribute.PortRange)); if (driverAtttribute.AltBasePort != 0x00) { ioPortRegions.AddLast(new IOPortRegion(driverAtttribute.AltBasePort, driverAtttribute.AltPortRange)); } if (driverAtttribute.BaseAddress != 0x00) { memoryRegions.AddLast(new MemoryRegion(driverAtttribute.BaseAddress, driverAtttribute.AddressRange)); } foreach (var memoryAttribute in deviceDriver.MemoryAttributes) { if (memoryAttribute.MemorySize > 0) { IMemory memory = Mosa.DeviceSystem.HAL.AllocateMemory(memoryAttribute.MemorySize, memoryAttribute.MemoryAlignment); memoryRegions.AddLast(new MemoryRegion(memory.Address, memory.Size)); } } var hardwareResources = new HardwareResources(resourceManager, ioPortRegions.ToArray(), memoryRegions.ToArray(), new InterruptHandler(resourceManager.InterruptManager, driverAtttribute.IRQ, hardwareDevice)); hardwareDevice.Setup(hardwareResources); Boot.Console.Write("Adding device "); Boot.InBrackets(hardwareDevice.Name, Mosa.Kernel.x86.Colors.White, Mosa.Kernel.x86.Colors.LightGreen); Boot.Console.WriteLine(); if (resourceManager.ClaimResources(hardwareResources)) { hardwareResources.EnableIRQ(); if (hardwareDevice.Start() == DeviceDriverStartStatus.Started) { deviceManager.Add(hardwareDevice); } else { hardwareResources.DisableIRQ(); resourceManager.ReleaseResources(hardwareResources); } } } }
static Fix() { sProc = Process.GetCurrentProcess(); sBaseAddr = sProc.MainModule.BaseAddress; sMem = new Memory(); }
private static void FillMemory(IMemory memory) => memory.SetString("hello");
public void SetupContext() { provider = new WebAPIProvider("Test2", "123", "http://localhost:58339"); }
// more fields can be added (see in visualGGPK) public ModRecord(IMemory m, StatsDat sDat, TagsDat tagsDat, long addr) { Address = addr; var ModsRecord = m.Read <ModsRecordOffsets>(addr); Key = RemoteMemoryObject.Cache.StringCache.Read($"{nameof(ModsDat)}{ModsRecord.Key.buf}", () => ModsRecord .Key.ToString( m)); // ModsRecord.Key.ToString(m);// m.ReadStringU(m.Read<long>(addr + 0)); Unknown8 = ModsRecord.Unknown8; // m.Read<long>(addr + 0x8); MinLevel = ModsRecord.MinLevel; // m.Read<int>(addr + 0x1C); // TypeName = m.ReadStringU(m.Read<long>(ModsRecord.TypeName /*m.Read<long>(addr + 0x14*/, 0),255); var read = m.Read <long>(ModsRecord.TypeName); TypeName = RemoteMemoryObject.Cache.StringCache.Read($"{nameof(ModsDat)}{read}", () => m.ReadStringU(read, 255)); var s1 = ModsRecord.StatNames1 == 0 ? 0 : m.Read <long>(ModsRecord.StatNames1); var s2 = ModsRecord.StatNames2 == 0 ? 0 : m.Read <long>(ModsRecord.StatNames2); var s3 = ModsRecord.StatNames3 == 0 ? 0 : m.Read <long>(ModsRecord.StatNames3); var s4 = ModsRecord.StatName4 == 0 ? 0 : m.Read <long>(ModsRecord.StatName4); StatNames = new[] { ModsRecord.StatNames1 == 0 ? null : sDat.records[RemoteMemoryObject.Cache.StringCache.Read($"{nameof(ModsDat)}{s1}", () => m.ReadStringU(s1))], ModsRecord.StatNames2 == 0 ? null : sDat.records[RemoteMemoryObject.Cache.StringCache.Read($"{nameof(ModsDat)}{s2}", () => m.ReadStringU(s2))], ModsRecord.StatNames3 == 0 ? null : sDat.records[RemoteMemoryObject.Cache.StringCache.Read($"{nameof(ModsDat)}{s3}", () => m.ReadStringU(s3))], ModsRecord.StatName4 == 0 ? null : sDat.records[RemoteMemoryObject.Cache.StringCache.Read($"{nameof(ModsDat)}{s4}", () => m.ReadStringU(s4))] }; Domain = (ModDomain)ModsRecord.Domain; //m.Read<int>(addr + 0x60); UserFriendlyName = RemoteMemoryObject.Cache.StringCache.Read($"{nameof(ModsDat)}{ModsRecord.UserFriendlyName}", () => m.ReadStringU( ModsRecord .UserFriendlyName)); //m.ReadStringU(ModsRecord.UserFriendlyName/*m.Read<long>(addr + 0x64)*/); AffixType = (ModType)ModsRecord.AffixType; //m.Read<int>(addr + 0x6C); Group = RemoteMemoryObject.Cache.StringCache.Read($"{nameof(ModsDat)}{ModsRecord.Group}", () => m.ReadStringU(ModsRecord.Group /*m.Read<long>(addr + 0x70)*/)); StatRange = new[] { /*new IntRange(m.Read<int>(addr + 0x78), m.Read<int>(addr + 0x7C)), * new IntRange(m.Read<int>(addr + 0x80), m.Read<int>(addr + 0x84)), * new IntRange(m.Read<int>(addr + 0x88), m.Read<int>(addr + 0x8C)), * new IntRange(m.Read<int>(addr + 0x90), m.Read<int>(addr + 0x94))*/ new IntRange(ModsRecord.StatRange1, ModsRecord.StatRange2), new IntRange(ModsRecord.StatRange3, ModsRecord.StatRange4), new IntRange(ModsRecord.StatRange5, ModsRecord.StatRange6), new IntRange(ModsRecord.StatRange7, ModsRecord.StatRange8) }; //Tags = new TagsDat.TagRecord[m.Read<long>(addr + 0x98)]; Tags = new TagsDat.TagRecord[ModsRecord.Tags]; var ta = ModsRecord.ta; // m.Read<long>(addr + 0xA0); for (var i = 0; i < Tags.Length; i++) { var ii = ta + 0x8 + 0x10 * i; var l = m.Read <long>(ii, 0); Tags[i] = tagsDat.Records[ RemoteMemoryObject.Cache.StringCache.Read($"{nameof(ModsDat)}{l}", () => m.ReadStringU(l, 255))]; } // TagChances = new Dictionary<string,int>(m.Read<int>(addr + 0xA8)); TagChances = new Dictionary <string, int>(ModsRecord.TagChances); var tc = ModsRecord.tc; //m.Read<long>(addr + 0xB0); for (var i = 0; i < Tags.Length; i++) { TagChances[Tags[i].Key] = m.Read <int>(tc + 4 * i); } IsEssence = ModsRecord.IsEssence == 0x01; // m.Read<byte>(addr + 0x1AC) == 0x01; // Tier = m.ReadStringU(m.Read<long>(addr + 0x1C5)); Tier = RemoteMemoryObject.Cache.StringCache.Read($"{nameof(ModsDat)}{ModsRecord.Tier}", () => m.ReadStringU(ModsRecord.Tier)); // m.ReadStringU(ModsRecord.Tier); }
public Engine(IMemory memory) : this(memory, EngineOptions.Default) { }
protected FileInMemory(IMemory m, Func <long> address) { M = m; Address = address(); fAddress = address; }
public T GetValue <T>(IMemoryOffset <T> offset) { using IMemory <T> mem = this.GetMemory(offset); return(mem.Value); }
internal protected MemoryObject Initialize(IMemory memory, MemoryAddress address) { Memory = memory; Address = address; return(this); }
public StringPointer(IMemory memory, MemoryAddress value, int maxLength) : this(memory, value, maxLength, Encoding.UTF8) { }
private static (object value, string error) Evaluator(Expression expression, IMemory state, Options options) { object result = null; string error; object instance; (instance, error) = expression.Children[0].TryEvaluate(state, options); if (error == null) { var isInstanceList = false; IList list = null; if (FunctionUtils.TryParseList(instance, out IList ilist)) { isInstanceList = true; list = ilist; } else if (instance is JObject jobj) { list = FunctionUtils.Object2KVPairList(jobj); } else if (FunctionUtils.ConvertToJToken(instance) is JObject jobject) { list = FunctionUtils.Object2KVPairList(jobject); } else { error = $"{expression.Children[0]} is not a collection or structure object to run foreach"; } if (error == null) { var iteratorName = (string)(expression.Children[1].Children[0] as Constant).Value; var stackedMemory = StackedMemory.Wrap(state); result = new List <object>(); for (var idx = 0; idx < list.Count; idx++) { var local = new Dictionary <string, object> { { iteratorName, FunctionUtils.AccessIndex(list, idx).value }, }; // the local iterator is pushed as one memory layer in the memory stack stackedMemory.Push(new SimpleObjectMemory(local)); var(r, e) = expression.Children[2].TryEvaluate(stackedMemory, new Options(options) { NullSubstitution = null }); stackedMemory.Pop(); if (FunctionUtils.IsLogicTrue(r) && e == null) { // add if only if it evaluates to true ((List <object>)result).Add(local[iteratorName]); } } if (!isInstanceList) { // re-construct object var jobjResult = new JObject(); foreach (var item in (List <object>)result) { FunctionUtils.TryAccessProperty(item, "key", out var keyVal); FunctionUtils.TryAccessProperty(item, "value", out var val); jobjResult.Add(keyVal as string, FunctionUtils.ConvertToJToken(val)); } result = jobjResult; } } } return(result, error); }
public ModsDat(IMemory m, Func <long> address, StatsDat sDat, TagsDat tagsDat) : base(m, address) { loadItems(sDat, tagsDat); }
private static (object value, string error) Evaluator(Expression expression, IMemory state, Options options) { TimexProperty parsed = null; string result = null; string error = null; var(validHour, validMinute, validSecond) = (0, 0, 0); IReadOnlyList <object> args; var formatRegex = new Regex("TXX:[0-5][0-9]:[0-5][0-9]"); var currentUtcTime = DateTime.UtcNow; var convertedDateTime = currentUtcTime; (args, error) = FunctionUtils.EvaluateChildren(expression, state, options); if (error == null) { if (!formatRegex.IsMatch(args[0] as string)) { error = $"{args[0]} must be a timex string which only contains minutes and seconds, for example: 'TXX:15:28'"; } } if (error == null) { if (args.Count == 2 && args[1] is string timezone) { object convertedTimeZone = null; (convertedTimeZone, error) = FunctionUtils.ConvertTimeZoneFormat(timezone); if (error == null) { convertedDateTime = TimeZoneInfo.ConvertTimeFromUtc(currentUtcTime, (TimeZoneInfo)convertedTimeZone); } } else { convertedDateTime = currentUtcTime.ToLocalTime(); } } if (error == null) { (parsed, error) = FunctionUtils.ParseTimexProperty((args[0] as string).Replace("XX", "00")); } if (error == null) { var(hour, minute, second) = (convertedDateTime.Hour, convertedDateTime.Minute, convertedDateTime.Second); if (parsed.Minute < minute || (parsed.Minute == minute && parsed.Second < second)) { validHour = hour; } else { validHour = hour - 1; } validMinute = parsed.Minute ?? 0; validSecond = parsed.Second ?? 0; result = TimexProperty.FromTime(new Time(validHour, validMinute, validSecond)).TimexValue; } return(result, error); }
public void UpdateFromMemoryWrite(IMemory oam, int oamAddress) { var updatedSpriteNumber = oamAddress / Sprite.SizeInBytes; UpdateSpriteFromOam(updatedSpriteNumber, oam); }
public OpCode64Id18(IMemory memory, IRegister register, Stack<ulong> ras) : base(memory,register) { this.ras = ras; }
/// <summary> /// Gets the physical address. /// </summary> /// <param name="memory">The memory.</param> /// <returns></returns> public static uint GetPhysicalAddress(IMemory memory) { return(hardwareAbstraction.GetPhysicalAddress(memory)); }
public WashProgramSelectedSignalHandler(IMemory memory) { _memory = memory; }