Ejemplo n.º 1
0
        public MachineCreateForm()
        {
            InitializeComponent();
            foreach (var devType in DeviceTypeRegistry.GetRegisteredDeviceTypes(out string[] types))
            {
                var attr = devType.GetCustomAttribute <DeviceComponentAttribute>();
                var icon = DeviceTypeRegistry.GetDeviceTypeIcon(devType.Name.ToLower());
                icons.Images.Add(devType.Name.ToLower(), icon);
            }

            machineComp = Machine.CreateDevice <MachineComponent>();
            eeprom      = Machine.CreateDevice <EEPROM>();
            scr         = Machine.CreateDevice <Screen>();
            gpu         = Machine.CreateDevice <GPU>();


            devices.Items.Add(new ListViewItem()
            {
                Text = machineComp.GetComponentAttribute().UserFriendlyName, Tag = machineComp, ImageKey = machineComp.GetType().Name.ToLower()
            });
            devices.Items.Add(new ListViewItem()
            {
                Text = eeprom.GetComponentAttribute().UserFriendlyName, Tag = eeprom, ImageKey = eeprom.GetType().Name.ToLower()
            });
            devices.Items.Add(new ListViewItem()
            {
                Text = scr.GetComponentAttribute().UserFriendlyName, Tag = scr, ImageKey = scr.GetType().Name.ToLower()
            });
            devices.Items.Add(new ListViewItem()
            {
                Text = gpu.GetComponentAttribute().UserFriendlyName, Tag = gpu, ImageKey = gpu.GetType().Name.ToLower()
            });
        }
Ejemplo n.º 2
0
        private void LaunchMachine(string machineDir)
        {
            //Machine machine = Machine.LoadMachine(machineDir, displayInterface);
            //machine.DeviceBus.ConnectDevice(machine.GetMachineComponent(), machine.GetMachineComponent().Address, true);
            //EEPROM eeprom = machine.DeviceBus.GetDevicesOfType<EEPROM>("eeprom")[0];
            //Screen scr = new Screen();
            //machine.DeviceBus.ConnectDevice(new GPU(), Guid.NewGuid(), true);
            //machine.DeviceBus.ConnectDevice(scr, Guid.NewGuid(), true);
            //eeprom.SetCode("local gpu = component.proxy(component.list('gpu')()); local screen = component.proxy(component.list('screen')()); gpu.bind(screen.address); gpu.set(0, 1, 'A');");
            //foreach (var dev in machine.DeviceBus.GetDevices())
            //{
            //    var devCompAttr = dev.GetComponentAttribute();
            //    if (devCompAttr.ShowStatusBarIcon)
            //        CreateIcon(dev.Address.ToString(), dev.DeviceIcon, GetTooltip(dev.Address.ToString(), devCompAttr.ComponentType, devCompAttr.DefaultTooltip));
            //}
            //var screens = machine.DeviceBus.GetDevicesOfType<Screen>(DeviceTypes.Screen);
            //if (screens.Length <= 0)
            //    throw new MachineCrashException("Unable to launch machine! No screen device found!");
            //currentScreenDevice = screens[0];


            foreach (var dev in machine.DeviceBus.GetDevices())
            {
                var devCompAttr = dev.GetComponentAttribute();
                if (devCompAttr.ShowStatusBarIcon)
                {
                    CreateIcon(dev.Address.ToString(), dev.DeviceIcon, GetTooltip(dev.Address.ToString(), devCompAttr.ComponentType, devCompAttr.DefaultTooltip));
                }
            }
            var screens = machine.DeviceBus.GetDevicesOfType <Screen>(DeviceTypes.Screen);

            if (screens.Length <= 0)
            {
                throw new MachineCrashException("Unable to launch machine! No screen device found!");
            }
            currentScreenDevice = screens[0];


            updater.Start();
            machine.Run(false);
        }