public MsxEmulationEnvironment(IDictionary <string, object> configDictionary, Action <string, object[]> tell, string machineName) { this.configDictionary = configDictionary; defaultEmulationParameters = configDictionary.GetValue <IDictionary <string, object> >("defaultEmulationParameters"); this.tell = tell; HostForm = new EmulatorHostForm(this); Z80 = new Z80Processor(); this.originalClockSynchronizer = Z80.ClockSynchronizer; this.machineName = machineName; LoadMachineConfig(); GenerateInjectedConfig(); var machineEmulationParameters = machineConfig.GetDictionaryOrDefault("emulationParameters"); var configToApply = injectedConfig.Keys.ToDictionary(k => k, k => injectedConfig[k]); machineEmulationParameters.MergeInto(configToApply); defaultEmulationParameters.MergeInto(configToApply); this.globalConfig = ConvertConfigDictionaryToObject(configToApply); globalConfig.GlobalPluginsConfig = configDictionary.GetDictionaryOrDefault("plugins"); globalConfig.SharedPluginsConfig = configDictionary.GetDictionaryOrDefault("sharedPluginsConfig"); HostForm.ApplyConfig(globalConfig); ConfigureCpu(); SlotsSystem = CreateEmptySlotsSystem(); KeyboardEventSource = HostForm; HostForm.SetFormTitle(this.machineName); Vdp = CreateVdp(HostForm); KeyboardController = CreateKeyboardController(HostForm); pluginContext = new PluginContext { Cpu = Z80, HostForm = HostForm, SlotsSystem = SlotsSystem, Vdp = Vdp, KeyEventSource = KeyboardEventSource, LoadedPlugins = null, SetMenuEntry = HostForm.SetPluginMenuEntry }; PluginsLoader = new PluginsLoader(pluginContext, tell); LoadGlobalPlugins(); LoadMachinePlugins(); CreateSlotsSystem(); var hardware = new MsxHardwareSet { Cpu = Z80, KeyboardController = KeyboardController, SlotsSystem = SlotsSystem, Vdp = Vdp }; emulator = new MsxEmulator(hardware); }
public MsxEmulator(MsxHardwareSet hardware) { this.hardware = hardware; hardware.Cpu.Memory = hardware.SlotsSystem; hardware.Cpu.RegisterInterruptSource(hardware.Vdp); hardware.Cpu.SetMemoryWaitStatesForM1(0, hardware.Cpu.Memory.Size, waitStates: 1); hardware.Cpu.MemoryAccess += Z80OnMemoryAccess; }