public void IOHexKeyboardTests_ReadFromMicro_Success() { VirtualMemory vm = new VirtualMemory(new string[] { "0000", "0000", "0000", "0000", "0000", "0000", "0000", "0000" }); IOManager manager = new IOManager(100); MicroSimulator micro = new MicroSimulator(vm, manager); Console.WriteLine("Initial State:"); Console.Write(vm); Console.WriteLine(manager); Console.WriteLine(micro); IOHexKeyboard kb = new IOHexKeyboard(5); manager.AddIODevice(5, kb); Console.WriteLine("\nAfter adding IO Hex Keyboard:"); Console.WriteLine(manager); Console.WriteLine($"\nIO Device: {kb}"); Assert.AreEqual("00", kb.ReadFromPort(5)); kb.KeyPress("A"); kb.KeyPress("A"); kb.KeyPress("A"); kb.KeyPress("F"); kb.KeyPress("A"); Console.WriteLine(kb); string contentHex = micro.ReadFromMemory(5); Assert.AreEqual("A1", contentHex); Console.WriteLine($"\nContent read in Hex: {contentHex}"); }
public void IOHexKeyboardTests_ExecuteOneInstruction_Success() { IOHexKeyboard kb = new IOHexKeyboard(90); Assert.AreEqual("00", kb.ReadFromPort(0)); kb.KeyPress("A"); kb.KeyPress("A"); kb.KeyPress("A"); kb.KeyPress("F"); kb.KeyPress("A"); kb.KeyPress("A"); Assert.AreEqual(4, kb.BufferSize); Console.WriteLine(kb); Assert.AreEqual("A1", kb.ReadFromPort(0)); Console.WriteLine(kb); }
public IOHexKeyboardUI(IOManager ioManager, ushort port) { InitializeComponent(); _ioManager = ioManager; // initialize IO Device Keyboard = new IOHexKeyboard(port); portNumber.Content = "0x" + UnitConverter.IntToHex(port, defaultWidth: 3); // try to add to IO Manager // exception wil be thrown if invalid port is selected _ioManager.AddIODevice(port, Keyboard); try { MouseDown += delegate { DragMove(); }; } catch (Exception) { } }