public RookieDriveFddPlugin(PluginContext context, IDictionary <string, object> pluginConfig) { kernelRoutines = new Dictionary <ushort, Action> { { 0x4010, DSKIO }, { 0x4013, () => DSKCHG_GETDPB(true) }, { 0x4016, () => DSKCHG_GETDPB(false) }, { 0x4019, CHOICE }, { 0x401C, DSKFMT }, { 0x401F, MTOFF } }; addressOfCallInihrd = pluginConfig.GetValueOrDefault <ushort>("addressOfCallInihrd", 0x176F); addressOfCallDrives = pluginConfig.GetValueOrDefault <ushort>("addressOfCallDrives", 0x1850); this.slotNumber = new SlotNumber(pluginConfig.GetValue <byte>("NestorMSX.slotNumber")); this.kernelFilePath = pluginConfig.GetMachineFilePath(pluginConfig.GetValueOrDefault("kernelFile", "MsxDosKernel.rom")); this.z80 = context.Cpu; this.memory = context.SlotsSystem; z80.BeforeInstructionFetch += (sender, args) => BeforeZ80InstructionFetch(z80.Registers.PC); this.kernelContents = File.ReadAllBytes(kernelFilePath); ValidateKernelFileContents(kernelContents); host = new UsbHost(new CH376UsbHostHardware(UsbServiceProvider.GetCH376Ports())); UpdateCbiInstance(); }
private FileSystemPlugin(PluginContext context, IDictionary <string, object> pluginConfig) { var defaultConfig = new Dictionary <string, object> { { "integratedDirectory", "$MyDocuments$/NestorMSX/FileSystem" }, { "volumeLabel", "NestorMSX" } }; defaultConfig.MergeInto(pluginConfig); basePath = pluginConfig.GetValue <string>("integratedDirectory") .Replace("/", "\\") .AsAbsolutePath(); volumeLabel = pluginConfig.GetValue <string>("volumeLabel"); currentFullDir = basePath; currentRelativeDir = ""; this.cpu = context.Cpu; this.regs = cpu.Registers; this.slotsSystem = context.SlotsSystem; this.mem = this.slotsSystem; cpu.BeforeInstructionFetch += CpuOnBeforeInstructionFetch; hookedMethods = new Dictionary <int, Action> { { 0x4020, ALLOC }, { 0x4023, FFIRST }, { 0x4026, FNEXT }, { 0x4029, CHDIR }, { 0x402C, GETCD }, { 0x402F, GETVOL } }; }
public RC2014(IZ80Processor cpu, IModule[] modules) { IPort[] ports = modules.Where(m => m is IPort).Cast <IPort>().ToArray(); IMemoryBank[] memoryBanks = modules.Where(m => m is IMemoryBank).Cast <IMemoryBank>().ToArray(); CPU = cpu; this.Ports = ports; CPU.Registers = new NotifiedZ80Registers(); CPU.Memory = new Memory(memoryBanks); CPU.AfterInstructionExecution += CPU_AfterInstructionExecution; var hiaddress = -1; foreach (IMemoryBank memoryBank in memoryBanks.OrderBy(m => m.LOW_ADDRESS)) { if (hiaddress + 1 < memoryBank.LOW_ADDRESS) { CPU.SetMemoryAccessMode((ushort)(hiaddress + 1), memoryBank.LOW_ADDRESS - hiaddress, MemoryAccessMode.NotConnected); } hiaddress = memoryBank.HI_ADDRESS; CPU.SetMemoryAccessMode((ushort)memoryBank.LOW_ADDRESS, memoryBank.SIZE, memoryBank.MemoryAccessMode); } foreach (var port in ports) { if (port is IZ80InterruptSource) { CPU.RegisterInterruptSource((IZ80InterruptSource)port); } } CPU.MemoryAccess += OnMemoryAccess; }
private KeyloggerFormPlugin(PluginContext context, IDictionary <string, object> pluginConfig) { this.context = context; this.z80 = context.Cpu; this.debugForm = new DebugForm(); this.debugForm.Show(context.HostForm); context.KeyEventSource.KeyPressed += KeyEventSourceOnKeyPressed; SetMenu(); }
public RookieDrivePortsPlugin(PluginContext context, IDictionary <string, object> pluginConfig) { context.Cpu.MemoryAccess += Cpu_MemoryAccess; chPorts = new CH376PortsViaNoobtocol((string)pluginConfig["serialPortNumber"]); cpu = context.Cpu; slots = context.SlotsSystem; context.Cpu.BeforeInstructionFetch += Cpu_BeforeInstructionFetch; ParseSymbols(@"C:\code\fun\RookieDrive\msx\.sym"); addressesToLog = symbolsToLog.ToDictionary(s => symbolsByName[s], s => s); //cpu.BeforeInstructionExecution += Cpu_BeforeInstructionExecution; }
/// <summary> /// Simulates the execution of a RET instruction by setting the value of the PC register /// from the value popped from the stack. /// </summary> /// <param name="processor"></param> public static void ExecuteRet(this IZ80Processor processor) { var registers = processor.Registers; var memory = processor.Memory; var sp = registers.SP.ToUShort(); var newPC = NumberUtils.CreateShort(memory[sp], memory[sp.Inc()]); registers.PC = newPC.ToUShort(); registers.SP = registers.SP.Add(2); }
public RookieDrivePortsPlugin(PluginContext context, IDictionary <string, object> pluginConfig) { context.Cpu.MemoryAccess += Cpu_MemoryAccess; chPorts = UsbServiceProvider.GetCH376Ports(); cpu = context.Cpu; slots = context.SlotsSystem; context.Cpu.BeforeInstructionFetch += Cpu_BeforeInstructionFetch; ParseSymbols(@"C:\code\fun\RookieDrive\msx\.sym"); addressesToLog = symbolsToLog.ToDictionary(s => symbolsByName[s], s => s); //cpu.BeforeInstructionExecution += Cpu_BeforeInstructionExecution; }
private CopyPastePlugin(PluginContext context, IDictionary <string, object> pluginConfig) { var defaultConfig = new Dictionary <string, object> { { "copyKey", null }, { "pasteKey", null }, { "encoding", "ASCII" } }; defaultConfig.MergeInto(pluginConfig); CopyKey = ParseKey(pluginConfig.GetValue <string>("copyKey")); PasteKey = ParseKey(pluginConfig.GetValue <string>("pasteKey")); var encodingName = pluginConfig.GetValue <string>("encoding"); try { Encoding = Encoding.GetEncoding(encodingName); } catch (Exception ex) { throw new ConfigurationException( $"Encoding '{encodingName}' is not supported by this system", ex); } if (CopyKey != Keys.None || PasteKey != Keys.None) { context.KeyEventSource.KeyReleased += KeyEventSourceOnKeyReleased; } this.Vdp = context.Vdp; this.processor = context.Cpu; processor.BeforeInstructionFetch += Cpu_BeforeInstructionFetch; context.Vdp.ScreenModeChanged += VdpOnScreenModeChanged; CopyMenuEntry = new MenuEntry($"Copy{(CopyKey == Keys.None ? "" : " (" + CopyKey + ")")}", CopyScreenAsText) { IsEnabled = false }; PasteMenuEntry = new MenuEntry($"Paste{(PasteKey == Keys.None ? "" : " (" + PasteKey + ")")}", PasteTextAsKeyboardData) { IsEnabled = false }; var mainMenuEntry = new MenuEntry("Copy && Paste", new[] { CopyMenuEntry, PasteMenuEntry }); context.SetMenuEntry(this, mainMenuEntry); }
/// <summary> /// Simulates the execution of a CALL instruction by pushing the current content of the PC register /// into the stack and setting it to the specified value. /// </summary> /// <param name="processor"></param> /// <param name="address">New value for the PC register</param> public static void ExecuteCall(this IZ80Processor processor, ushort address) { var registers = processor.Registers; var memory = processor.Memory; var oldAddress = registers.PC.ToShort(); var sp = registers.SP.Dec(); memory[sp.ToUShort()] = oldAddress.GetHighByte(); sp = sp.Dec(); memory[sp.ToUShort()] = oldAddress.GetLowByte(); registers.SP = sp; registers.PC = address; }
private TcpipUnapiPlugin(PluginContext context, IDictionary <string, object> pluginConfig) { slotNumber = new SlotNumber((byte)pluginConfig["NestorMSX.slotNumber"]); cpu = context.Cpu; slots = context.SlotsSystem; cpu.BeforeInstructionFetch += Cpu_BeforeInstructionFetch; bool hasIp(NetworkInterface iface, string ip) { return(iface.GetIPProperties().UnicastAddresses.Any(a => a.Address.ToString() == ip)); } bool hasIpv4Address(NetworkInterface iface) { return(iface.GetIPProperties().UnicastAddresses.Any(a => IsIPv4(a.Address))); } var ipAddress = pluginConfig.GetValueOrDefault("ipAddress", ""); var networkInterfaces = NetworkInterface.GetAllNetworkInterfaces() .Where(i => i.Supports(NetworkInterfaceComponent.IPv4)); if (ipAddress == "") { networkInterface = networkInterfaces.FirstOrDefault(i => hasIpv4Address(i) && i.NetworkInterfaceType != NetworkInterfaceType.Loopback) ?? networkInterfaces.FirstOrDefault(i => hasIpv4Address(i)); ipInfo = networkInterface?.GetIPProperties().UnicastAddresses.First(a => IsIPv4(a.Address)); } else { networkInterface = networkInterfaces.FirstOrDefault(i => hasIp(i, ipAddress)); ipInfo = networkInterface?.GetIPProperties().UnicastAddresses.First(a => a.Address.ToString() == ipAddress); } if (networkInterface == null) { throw new Exception(ipAddress == "" ? "No IPv4 network interfaces available" : $"There is no network interface with the IP address {ipAddress}"); } dnsServersAvailable = networkInterface.GetIPProperties().DnsAddresses.Any(); mtu = (short)Math.Min(32767, networkInterface.GetIPProperties().GetIPv4Properties().Mtu); InitRoutinesArray(); }