Exemplo n.º 1
0
 protected ImmutableState(ImmutableState prev, Register register, ushort value)
 {
     _memory = prev._memory;
     _regs = prev._regs.Set((int)register, value);
     _deviceStates = prev._deviceStates;
     _memoryMap = prev._memoryMap;
 }
Exemplo n.º 2
0
 public MutableState()
 {
     _memory = new ushort[Dcpu.MAX_ADDRESS + 1];
     _regs = new ushort[11];
     _memoryMap = new MemoryMap();
     _deviceStates = new Dictionary<string, DeviceState>();
 }
Exemplo n.º 3
0
 protected ImmutableState(ushort[] memory)
 {
     _memory = new PersistentArray<ushort>(memory);
     _regs = new PersistentArray<ushort>(11);
     _deviceStates = new Dictionary<string, DeviceState>();
     _memoryMap = new MemoryMap();
 }
Exemplo n.º 4
0
 public ImmutableState()
 {
     _memory = new PersistentArray<ushort>(Dcpu.MAX_ADDRESS + 1);
     _regs = new PersistentArray<ushort>(11);
     _deviceStates = new Dictionary<string, DeviceState>();
     _memoryMap = new MemoryMap();
 }
Exemplo n.º 5
0
 protected ImmutableState(ImmutableState prev, IEvent e)
 {
     _memory = prev._memory;
     _regs = prev._regs;
     _memoryMap = prev._memoryMap;
     _deviceStates = new Dictionary<string, DeviceState>(prev._deviceStates);
     _deviceStates[e.DeviceId] = _deviceStates[e.DeviceId].Handle(e);
 }
Exemplo n.º 6
0
 protected ImmutableState(ImmutableState prev, ushort from, ushort to, DeviceState device)
 {
     _memory = prev._memory;
     _regs = prev._regs;
     _memoryMap = new MemoryMap(prev._memoryMap);
     _memoryMap.Map(from, to, device.Id);
     _deviceStates = new Dictionary<string,DeviceState>(prev._deviceStates);
     _deviceStates[device.Id] = device;
 }
Exemplo n.º 7
0
 protected ImmutableState(ImmutableState prev, ushort addr, ushort value)
 {
     _memory = prev._memory;
     _regs = prev._regs;
     _memoryMap = prev._memoryMap;
     var deviceId = prev._memoryMap[addr];
     if (deviceId == null) {
         _memory = _memory.Set(addr, value);
         _deviceStates = prev._deviceStates;
     } else {
         _deviceStates = new Dictionary<string, DeviceState>(prev._deviceStates);
         _deviceStates[deviceId] = prev._deviceStates[deviceId].Write(addr, value);
     }
 }
Exemplo n.º 8
0
 public MemoryMap(MemoryMap map)
 {
     _mappedRanges = new List<MappedRange>();
     _mappedRanges.AddRange(map._mappedRanges);
 }