Esempio n. 1
0
        /// <summary>
        /// Method for performing the OUT instruction
        /// </summary>
        public static bool Output(ModuleBase module, MixInstruction.Instance instance)
        {
            if (module.Devices == null)
            {
                module.ReportRuntimeError("Module does not provide devices");
                return(false);
            }

            var mValue = InstructionHelpers.GetValidIndexedAddress(module, instance.AddressValue, instance.Index);

            if (mValue == int.MinValue)
            {
                return(false);
            }

            int       deviceIndex = instance.FieldSpec.MixByteValue.ByteValue;
            MixDevice device      = module.Devices[deviceIndex];

            if (!device.SupportsOutput)
            {
                module.ReportRuntimeError("Device " + deviceIndex + " doesn't support output");
                return(false);
            }

            if (device.Busy)
            {
                return(false);
            }

            var field = WordField.LoadFromRegister(new FieldSpec(4, 5), module.Registers.RX);

            device.StartOutput(module.Memory, mValue, (int)field.LongValue, module is Mix && ((Mix)module).Mode == ModuleBase.RunMode.Control ? new InterruptQueueCallback(((Mix)module).QueueInterrupt) : null);

            return(true);
        }
Esempio n. 2
0
 public void ShowDevice(MixDevice device)
 {
     if (device is DiskDevice)
     {
         mDeviceTypeTabs.SelectedIndex      = disksTabIndex;
         mDiskSelectorComboBox.SelectedItem = device;
     }
     else if (device is TapeDevice)
     {
         mDeviceTypeTabs.SelectedIndex      = tapesTabIndex;
         mTapeSelectorComboBox.SelectedItem = device;
     }
     else if (device is CardReaderDevice)
     {
         mDeviceTypeTabs.SelectedIndex = cardReaderTabIndex;
     }
     else if (device is CardWriterDevice)
     {
         mDeviceTypeTabs.SelectedIndex = cardWriterTabIndex;
     }
     else if (device is PrinterDevice)
     {
         mDeviceTypeTabs.SelectedIndex = printerTabIndex;
     }
     else if (device is PaperTapeDevice)
     {
         mDeviceTypeTabs.SelectedIndex = paperTapeTabIndex;
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Method for performing the JRED instruction
        /// </summary>
        public static bool JumpIfReady(ModuleBase module, MixInstruction.Instance instance)
        {
            if (module.Devices == null)
            {
                module.ReportRuntimeError("Module does not provide devices");
                return(false);
            }

            var indexedAddress = InstructionHelpers.GetValidIndexedAddress(module, instance.AddressValue, instance.Index);

            if (indexedAddress == int.MinValue)
            {
                return(false);
            }

            int       deviceIndex = instance.FieldSpec.MixByteValue.ByteValue;
            MixDevice device      = module.Devices[deviceIndex];

            if (!device.Busy)
            {
                JumpInstructions.Jump(module, indexedAddress);
                return(false);
            }

            return(true);
        }
Esempio n. 4
0
        public DeviceStatusControl(MixDevice device)
        {
            mDevice = device;

            mIndexLabel       = new Label();
            mStatusLabel      = new Label();
            mContextMenu      = new ContextMenu();
            mInputMenuItem    = new MenuItem();
            mOutputMenuItem   = new MenuItem();
            mContextSeparator = new MenuItem();
            mResetMenuItem    = new MenuItem();

            SuspendLayout();

            mIndexLabel.Location     = new Point(0, 0);
            mIndexLabel.Name         = "mIndexLabel";
            mIndexLabel.Size         = new Size(20, 16);
            mIndexLabel.TabIndex     = 0;
            mIndexLabel.Text         = "00:";
            mIndexLabel.TextAlign    = ContentAlignment.MiddleRight;
            mIndexLabel.DoubleClick += Control_DoubleClick;

            mStatusLabel.BorderStyle  = BorderStyle.FixedSingle;
            mStatusLabel.Location     = new Point(20, 0);
            mStatusLabel.Name         = "mStatusLabel";
            mStatusLabel.Size         = new Size(32, 16);
            mStatusLabel.TabIndex     = 1;
            mStatusLabel.Text         = "";
            mStatusLabel.TextAlign    = ContentAlignment.MiddleCenter;
            mStatusLabel.DoubleClick += Control_DoubleClick;

            mInputMenuItem.Index = 0;
            mInputMenuItem.Text  = "Input device";

            mOutputMenuItem.Index = 1;
            mOutputMenuItem.Text  = "Output device";

            mContextSeparator.Index = 2;
            mContextSeparator.Text  = "-";

            mResetMenuItem.DefaultItem = true;
            mResetMenuItem.Index       = 3;
            mResetMenuItem.Text        = "Reset";
            mResetMenuItem.Click      += MResetMenuItem_Click;

            mContextMenu.MenuItems.AddRange(new MenuItem[] { mInputMenuItem, mOutputMenuItem, mContextSeparator, mResetMenuItem });
            ContextMenu = mContextMenu;

            Controls.Add(mIndexLabel);
            Controls.Add(mStatusLabel);
            Name = "DeviceStatusControl";
            Size = new Size(mIndexLabel.Width + mStatusLabel.Width, 16);
            ResumeLayout(false);

            UpdateLayout();
        }
Esempio n. 5
0
        /// <summary>
        /// Method for performing the IOC instruction
        /// </summary>
        public static bool IOControl(ModuleBase module, MixInstruction.Instance instance)
        {
            if (module.Devices == null)
            {
                module.ReportRuntimeError("Module does not provide devices");
                return(false);
            }

            var       indexedAddress = module.Registers.GetIndexedAddress(instance.AddressValue, instance.Index);
            int       deviceIndex    = instance.FieldSpec.MixByteValue.ByteValue;
            MixDevice device         = module.Devices[deviceIndex];

            if (device.Busy)
            {
                return(false);
            }

            var field = WordField.LoadFromRegister(new FieldSpec(4, 5), module.Registers.RX);

            device.StartIoc(indexedAddress, (int)field.LongValue, module is Mix && ((Mix)module).Mode == ModuleBase.RunMode.Control ? new InterruptQueueCallback(((Mix)module).QueueInterrupt) : null);

            return(true);
        }
Esempio n. 6
0
 public DeviceEventArgs(MixDevice device)
 {
     Device = device;
 }
Esempio n. 7
0
 public DeviceReportingEventArgs(MixDevice reportingDevice, Severity severity, string message)
     : base(severity, message)
 {
     ReportingDevice = reportingDevice;
 }