Exemplo n.º 1
0
        static void Main(string[] args)
        {
            if (args.Length == 0) {
                PrintUsage();
                Environment.Exit(1);
            }

            var keyboardState = new KeyboardState();
            var displayState = new DisplayState();
            IState state = ImmutableState.ReadFromFile(args[0]);
            state = state.Map((ushort)KeyboardState.BufferAddress,
                (ushort)(KeyboardState.BufferAddress + KeyboardState.BufferLength + 1),
                keyboardState);
            state = state.Map((ushort)DisplayState.DisplayAddress,
                (ushort)(DisplayState.DisplayAddress + DisplayState.Width * DisplayState.Height),
                displayState);
            _cpu = new Dcpu(state);

            var mainForm = new MainForm(_cpu, displayState);

            mainForm.FormClosed += new FormClosedEventHandler( (obj, arg) => _cpu.Stop());

            Application.EnableVisualStyles();
            Application.Run(mainForm);
        }
Exemplo n.º 2
0
 public void ResetBuffer(DisplayState displayState)
 {
     for (int i=0; i < DisplayState.Width * DisplayState.Height; ++i) {
         _buffer[i] = displayState.Read((ushort)(DisplayState.DisplayAddress + i));
     }
     Invalidate();
 }
Exemplo n.º 3
0
 public override DeviceState Write(ushort addr, ushort newValue)
 {
     var next = new DisplayState(this);
     var oldValue = _displayMemory[addr - DisplayAddress];
     next._displayMemory = next._displayMemory.Set(addr - DisplayAddress, newValue);
     TriggerOnWrite(addr, oldValue, newValue);
     return next;
 }
Exemplo n.º 4
0
        public MainForm(Dcpu dcpu, DisplayState initialDisplayState)
        {
            InitializeComponent();
            _dcpu = dcpu;

            _savedDcpuStates = new List<IState>(NumSavedDcpuStates);
            _dcpuStateTimer = new Timer();
            _dcpuStateTimer.Tick += HandleDcpuStateTimerTick;
            _dcpuStateTimer.Interval = DcpuSavedStateInterval;

            _stopStartBtn.Text = "Start";
            _terminalPanel.Dcpu = dcpu;
            _terminalPanel.BindTo(initialDisplayState);

            _timeTrackBar.Maximum = NumSavedDcpuStates - 1;
            _timeTrackBar.Value = NumSavedDcpuStates - 1;
        }
Exemplo n.º 5
0
 public void BindTo(DisplayState displayState)
 {
     displayState.OnWrite += new EventHandler<DeviceWriteEventArgs>(HandleDisplayUpdate);
 }
Exemplo n.º 6
0
 protected DisplayState(DisplayState prev)
     : base(prev)
 {
     _displayMemory = prev._displayMemory;
 }