Inheritance: Tomato.Hardware.Device
Example #1
0
 public GenerickeyboardWindow(LEM1802 LEM1802, DCPU CPU, bool AssignKeyboard)
     : base(LEM1802, CPU, AssignKeyboard)
 {
     this.Text = "Generic Keyboard";
     this.Name = "test";
     this.takeScreenshotToolStripMenuItem.Enabled = false;
 }
Example #2
0
        /// <summary>
        /// Assigns a LEM to the window.  If AssignKeyboard is true, it will search for a keyboard
        /// in the given CPU and assign it to this window as well.
        /// </summary>
        public LEM1802Window(LEM1802 LEM1802, DCPU CPU, bool AssignKeyboard)
            : base()
        {
            InitializeComponent();
            this.iad = new InvalidateAsyncDelegate(InvalidateAsync);
            startRecordingToolStripMenuItem.Tag = false;
            // Set up drawing
            this.SetStyle(ControlStyles.AllPaintingInWmPaint |
              ControlStyles.UserPaint | ControlStyles.Opaque, true);

            // Take a screen
            this.CPU = CPU;
            Screen = LEM1802;
            managedDevices = new Device[] { Screen };
            ScreenIndex = CPU.Devices.IndexOf(Screen);

            Keyboard = null;

            // Take a keyboard
            if (AssignKeyboard)
            {
                for (int i = 0; i < CPU.Devices.Count; i++)
                {
                    if (AssignedKeyboards.Contains(i))
                        continue;
                    if (CPU.Devices[i] is GenericKeyboard)
                    {
                        Keyboard = CPU.Devices[i] as GenericKeyboard;
                        managedDevices = managedDevices.Concat(new Device[] { Keyboard }).ToArray();
                        AssignedKeyboards.Add(i);
                        KeyboardIndex = i;
                        this.detatchKeyboardToolStripMenuItem.Visible = true;
                        break;
                    }
                }
            }
            this.KeyDown += new KeyEventHandler(LEM1802Window_KeyDown);
            this.KeyUp += new KeyEventHandler(LEM1802Window_KeyUp);
            if (this.Keyboard == null)
            {
                this.DragEnter += new DragEventHandler(LEM1802Window_DragEnter);
                this.DragDrop += new DragEventHandler(LEM1802Window_DragDrop);
                this.AllowDrop = true;
            }
            timer = new System.Threading.Timer(delegate(object o)
                {
                    InvalidateAsync();
                }, null, 16, 16); // 60 Hz
            InitClientSize();
        }
Example #3
0
        /// <summary>
        /// Assigns a LEM to the window.  If AssignKeyboard is true, it will search for a keyboard
        /// in the given CPU and assign it to this window as well.
        /// </summary>
        public LEM1802Window(LEM1802 LEM1802, DCPU CPU, bool AssignKeyboard)
        {
            InitializeComponent();
            // Set up drawing
            this.SetStyle(ControlStyles.AllPaintingInWmPaint |
              ControlStyles.UserPaint | ControlStyles.Opaque, true);

            // Take a screen
            Screen = LEM1802;
            ScreenIndex = CPU.Devices.IndexOf(Screen);

            Keyboard = null;

            // Take a keyboard
            if (AssignKeyboard)
            {
                for (int i = 0; i < CPU.Devices.Count; i++)
                {
                    if (AssignedKeyboards.Contains(i))
                        continue;
                    if (CPU.Devices[i] is GenericKeyboard)
                    {
                        Keyboard = CPU.Devices[i] as GenericKeyboard;
                        AssignedKeyboards.Add(i);
                        KeyboardIndex = i;
                        break;
                    }
                }
                this.KeyDown += new KeyEventHandler(LEM1802Window_KeyDown);
                this.KeyUp += new KeyEventHandler(LEM1802Window_KeyUp);
            }
            timer = new System.Threading.Timer(delegate(object o)
                {
                    InvalidateAsync();
                }, null, 16, 16); // 60 Hz
            FormClosing += new FormClosingEventHandler(LEM1802Window_FormClosing);
            InitClientSize();
        }
Example #4
0
        private static void DrawScreen(LEM1802 Screen)
        {
            ConsoleColor foregroundInitial = Console.ForegroundColor;
            ConsoleColor backgroundInitial = Console.BackgroundColor;
            ushort address = 0;
            Console.ForegroundColor = GetPaletteColor((byte)Screen.BorderColorValue);
            Console.Write("                                  \n");
            for (int y = 0; y < 12; y++)
            {
                Console.ForegroundColor = GetPaletteColor((byte)Screen.BorderColorValue);
                Console.Write(" ");
                for (int x = 0; x < 32; x++)
                {
                    ushort value = CPU.Memory[Screen.ScreenMap + address];

                    ConsoleColor background = GetPaletteColor((byte)((value & 0xF00) >> 8));
                    ConsoleColor foreground = GetPaletteColor((byte)((value & 0xF000) >> 12));
                    Console.ForegroundColor = foreground;
                    Console.BackgroundColor = background;
                    Console.Write(Encoding.ASCII.GetString(new byte[] { (byte)(value & 0xFF) }));
                    address++;
                }
                Console.ForegroundColor = GetPaletteColor((byte)Screen.BorderColorValue);
                Console.Write(" \n");
            }
            Console.ForegroundColor = foregroundInitial;
            Console.BackgroundColor = backgroundInitial;
        }
Example #5
0
 public void PrepareDevice()
 {
     this.m_LEM1802 = new LEM1802();
 }