public MyGame(IEmulator emulator) { this.emulator = emulator; graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; IsFixedTimeStep = false; }
public CoreInfo(IEmulator emu) { TypeName = emu.GetType().ToString(); CoreName = emu.Attributes().CoreName; Released = emu.Attributes().Released; Services = new Dictionary<string, ServiceInfo>(); var ser = emu.ServiceProvider; foreach (Type t in ser.AvailableServices.Where(type => type != emu.GetType())) { var si = new ServiceInfo(t, ser.GetService(t)); Services.Add(si.TypeName, si); } var notapplicableAttr = ((ServiceNotApplicable)Attribute .GetCustomAttribute(emu.GetType(), typeof(ServiceNotApplicable))); if (notapplicableAttr != null) { NotApplicableTypes = notapplicableAttr.NotApplicableTypes .Select(x => x.ToString()) .ToList(); } else { NotApplicableTypes = new List<string>(); } }
public void Execute(IEmulator emulator) { var debugger = emulator as IDebuggingEmulator; if (debugger == null) return; debugger.DumpMemory(); }
public void Execute(IEmulator emulator) { var debugger = emulator as IDebuggingEmulator; if (debugger == null) return; debugger.SetMemoryWatch8(MemoryAddress); }
public EmulatorWindow() { InitializeComponent(); //cpu = new Cpu(new ushort[0x1000]); cpu = new AltCPU(); //AltEmulatorProxy.Test(); this.memDump.ReadOnly = false; mem = new ushort[0x10000]; memoryTip.SetToolTip(this.cpuMemLabel, "This is only how much memory you see - "+ "it does not affect the total available memory. "+ "Higher numbers are slower." ); }
public MainWindow() { InitializeComponent(); emulator = new GameBoyEmulator(); emulator.RenderHandler += emulator_Render; DataContext = emulator; renderFrame = new WriteableBitmap(emulator.RenderWidth, emulator.RenderHeight, 96, 96, PixelFormats.Gray8, null); renderedImage.Source = renderFrame; // To be used for writing a new frame to renderFrame renderRectangle = new Int32Rect(0, 0, emulator.RenderWidth, emulator.RenderHeight); }
public DebugRegisters(IEmulator emulator) { //initialize the form ShowIcon = false; MaximizeBox = false; MinimizeBox = false; FormBorderStyle = FormBorderStyle.FixedSingle; //get the processors p_Emulator = emulator; p_Processors = emulator.GetProcessors(); // int[] col; getTable(out col); }
private static AutofireController BindToDefinitionAF(ControllerDefinition def, IEmulator emulator, IDictionary<string, Dictionary<string, string>> allbinds) { var ret = new AutofireController(def, emulator); Dictionary<string, string> binds; if (allbinds.TryGetValue(def.Name, out binds)) { foreach (var cbutton in def.BoolButtons) { string bind; if (binds.TryGetValue(cbutton, out bind)) { ret.BindMulti(cbutton, bind); } } } return ret; }
public void Execute(IEmulator emulator) { IStatefulEmulator e = emulator as IStatefulEmulator; String stateFolder = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Wren", "SaveState" ); Directory.CreateDirectory(stateFolder); using (var file = File.Open(Path.Combine(stateFolder, _game.Id + _saveSlot + ".state"), FileMode.Create, FileAccess.Write)) { e.SaveState(new BinaryWriter(file)); } }
public void Execute(IEmulator emulator) { IStatefulEmulator e = emulator as IStatefulEmulator; String stateFolder = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Wren", "SaveState" ); Directory.CreateDirectory(stateFolder); String filePath = Path.Combine(stateFolder, _game.Id + _saveSlot + ".state"); if (!File.Exists(filePath)) return; using (var file = File.Open(filePath, FileMode.Open, FileAccess.Read)) { e.LoadState(new BinaryReader(file)); } }
public Win32LuaLibraries( IEmulatorServiceProvider serviceProvider, MainForm mainForm, IDisplayManagerForApi displayManager, InputManager inputManager, Config config, IEmulator emulator, IGameInfo game) { void EnumerateLuaFunctions(string name, Type type, LuaLibraryBase instance) { if (instance != null) { _lua.NewTable(name); } foreach (var method in type.GetMethods()) { var foundAttrs = method.GetCustomAttributes(typeof(LuaMethodAttribute), false); if (foundAttrs.Length == 0) { continue; } if (instance != null) { _lua.RegisterFunction($"{name}.{((LuaMethodAttribute) foundAttrs[0]).Name}", instance, method); } Docs.Add(new LibraryFunction( name, type.GetCustomAttributes(typeof(DescriptionAttribute), false).Cast <DescriptionAttribute>() .Select(descAttr => descAttr.Description).FirstOrDefault() ?? string.Empty, method )); } } if (true /*NLua.Lua.WhichLua == "NLua"*/) { _lua["keepalives"] = _lua.NewTable(); } _th = new NLuaTableHelper(_lua); _displayManager = displayManager; _inputManager = inputManager; _mainForm = mainForm; LuaWait = new AutoResetEvent(false); Docs.Clear(); _apiContainer = ApiManager.RestartLua(serviceProvider, LogToLuaConsole, _mainForm, _displayManager, _inputManager, _mainForm.MovieSession, _mainForm.Tools, config, emulator, game); // Register lua libraries foreach (var lib in Client.Common.ReflectionCache.Types.Concat(EmuHawk.ReflectionCache.Types) .Where(t => typeof(LuaLibraryBase).IsAssignableFrom(t) && t.IsSealed && ServiceInjector.IsAvailable(serviceProvider, t))) { bool addLibrary = true; var attributes = lib.GetCustomAttributes(typeof(LuaLibraryAttribute), false); if (attributes.Any()) { addLibrary = VersionInfo.DeveloperBuild || ((LuaLibraryAttribute)attributes.First()).Released; } if (addLibrary) { var instance = (LuaLibraryBase)Activator.CreateInstance(lib, this, _apiContainer, (Action <string>)LogToLuaConsole); ServiceInjector.UpdateServices(serviceProvider, instance); // TODO: make EmuHawk libraries have a base class with common properties such as this // and inject them here if (instance is ClientLuaLibrary clientLib) { clientLib.MainForm = _mainForm; } else if (instance is ConsoleLuaLibrary consoleLib) { consoleLib.Tools = _mainForm.Tools; _logToLuaConsoleCallback = consoleLib.Log; } else if (instance is GuiLuaLibrary guiLib) { guiLib.CreateLuaCanvasCallback = (width, height, x, y) => { var canvas = new LuaCanvas(width, height, x, y, _th, LogToLuaConsole); canvas.Show(); return(_th.ObjectToTable(canvas)); }; } else if (instance is TAStudioLuaLibrary tastudioLib) { tastudioLib.Tools = _mainForm.Tools; } EnumerateLuaFunctions(instance.Name, lib, instance); Libraries.Add(lib, instance); } } _lua.RegisterFunction("print", this, GetType().GetMethod("Print")); EmulationLuaLibrary.FrameAdvanceCallback = Frameadvance; EmulationLuaLibrary.YieldCallback = EmuYield; EnumerateLuaFunctions(nameof(LuaCanvas), typeof(LuaCanvas), null); // add LuaCanvas to Lua function reference table }
public AchievementHelpers(Achievement achievement, AchievementsManager achievementsManager, IEmulator emulator) { _achievementsManager = achievementsManager; _achievement = achievement; _emulator = emulator; }
public static void UpdateEmulatorAndVP(IEmulator emu = null) { Emulator = emu; VideoProvider = emu.AsVideoProviderOrDefault(); }
public IEnumerable <PadSchema> GetPadSchemas(IEmulator core, Action <string> showMessageBox) { var nyma = (NymaCore)core; return(NymaSchemas(nyma, showMessageBox)); }
public void Execute(IEmulator emulator) { emulator.Quit(); }
public IEnumerable <PadSchema> GetPadSchemas(IEmulator core) { yield return(StandardController()); }
public static bool EnsureCoreIsAccurate(IEmulator emulator) {
public void Start(EmulationContext context, IEventAggregator eventAggregator, EmulationMode mode) { _emulator = _emulatorRegistry.GetEmulator(context.EmulatedSystem, _handle); IRomSource loader = null; if (context.Game.RomPath.ToLower().EndsWith(".zip")) { loader = new ZipRomSource(context.Game.RomPath); } else { loader = new FileRomSource(context.Game.RomPath); } using (var romData = loader.GetRomData()) { if (!_emulator.IsRomValid(romData)) return; romData.Seek(0, System.IO.SeekOrigin.Begin); _emulator.LoadRom(romData, null); } eventAggregator.Publish(new EmulatorStartingEvent(InstanceId, this, context.Game, mode)); while (_bus.HasMessages) { _bus.GetCommand().Execute(_emulator); } _emulator.Initialize(eventAggregator); int pixelWidth, pixelHeight; Wren.Core.PixelFormats requestedPixelFormat; Int32 framePerSecond; // assemble rendering pipeline _emulator.GetSpecifications(out pixelWidth, out pixelHeight, out framePerSecond, out requestedPixelFormat); var rSource = _renderingSourceFactory.Create(pixelWidth, pixelHeight, requestedPixelFormat); eventAggregator.Publish(new RenderingSurfaceCreatedEvent(this.InstanceId, rSource.MemorySection, rSource.RenderingSurface, rSource.SurfaceInformation)); _emulator.SetRenderingSurface(rSource.RenderingSurface); var input = _inputPipeline.BuildInputSource(context); eventAggregator.Publish(new EmulatorStartedEvent(this.InstanceId)); FrameRateTimer fp = _frameRateTimerFactory.GetFrameRateTimer(framePerSecond); fp.ScheduleAction(() => { while (_bus.HasMessages) { _bus.GetCommand().Execute(_emulator); } _emulator.SetInput(input.GetCurrentInputState()); Boolean isRunning; try { isRunning = _emulator.Run(); } catch { isRunning = false; } eventAggregator.Publish(new FrameRenderedEvent(this.InstanceId)); if (!isRunning) { eventAggregator.Publish(new EmulatorQuitEvent(this.InstanceId)); input.Close(); } return isRunning; }); if (!fp.IsRunning) { fp.Start(); } }
/*Run button also qualifies as the pause button.*/ private void menu_build_run(object sender, EventArgs e) { //emulator running? if (p_Emulator != null) { //resume/suspend if (p_Emulator.Suspended) { p_Emulator.Resume(); } else { p_Emulator.Suspend(); } //update the menu buttons for the run/suspend function p_MenuStripRunButton.Image = Icons.GetBitmap( "tools." + (p_Emulator.Suspended ? "run" : "pause"), 16); p_DropDownRunButton.Text = (p_Emulator.Suspended ? "Resume" : "Pause"); p_DropDownRunButton.Image = p_MenuStripRunButton.Image; return; } //build and run ICompilerOutput<Solution> output = tryBuild(); if (output == null) { return; } readOnlyMode(true); p_Emulator = output.CreateEmulator(); p_Emulator.Start(16, delegate(string line) { p_OutputWindow.WriteLine(line); }); Text = p_Title + " (Running)"; //update the menu buttons p_MenuStripRunButton.Image = Icons.GetBitmap("tools.pause",16); p_DropDownRunButton.Image = p_MenuStripRunButton.Image; p_DropDownRunButton.Text = "Pause"; //create a timer to automatically set the state to "not running" //when the process is closed Timer timer = new Timer() { Interval = 10, Enabled = true }; timer.Tick += delegate(object s, EventArgs a) { if (!p_Emulator.Running) { p_MenuStripRunButton.Image = Icons.GetBitmap("tools.run", 16); p_DropDownRunButton.Image = p_MenuStripRunButton.Image; p_DropDownRunButton.Text = "Run"; p_Emulator = null; ((Timer)s).Enabled = false; readOnlyMode(false); Text = p_Title; } }; }
public AutofireController(ControllerDefinition definition, IEmulator emulator) { On = Global.Config.AutofireOn < 1 ? 0 : Global.Config.AutofireOn; Off = Global.Config.AutofireOff < 1 ? 0 : Global.Config.AutofireOff; _type = definition; _emulator = emulator; }
public void QueueNewMovie(IMovie movie, bool record, IEmulator emulator) { if (!record) // The semantics of record is that we are starting a new movie, and even wiping a pre-existing movie with the same path, but non-record means we are loading an existing movie into playback mode { movie.Load(false); if (movie.SystemID != emulator.SystemId) { throw new MoviePlatformMismatchException( string.Format( "Movie system Id ({0}) does not match the currently loaded platform ({1}), unable to load", movie.SystemID, emulator.SystemId)); } } // TODO: Delete this, this save is utterly useless. // Movie was saved immediately before calling QueeuNewMovie. (StartNewMovie) //if (Movie.IsActive && !string.IsNullOrEmpty(Movie.Filename)) //{ // Movie.Save(); //} // Note: this populates MovieControllerAdapter's Type with the approparite controller // Don't set it to a movie instance of the adapter or you will lose the definition! InputManager.RewireInputChain(); if (!record && emulator.SystemId == "NES") // For NES we need special logic since the movie will drive which core to load { var quicknesName = ((CoreAttributes)Attribute.GetCustomAttribute(typeof(QuickNES), typeof(CoreAttributes))).CoreName; var neshawkName = ((CoreAttributes)Attribute.GetCustomAttribute(typeof(NES), typeof(CoreAttributes))).CoreName; // If either is specified use that, else use whatever is currently set if (movie.Core == quicknesName) { PreviousNES_InQuickNES = Global.Config.NES_InQuickNES; Global.Config.NES_InQuickNES = true; } else if (movie.Core == neshawkName) { PreviousNES_InQuickNES = Global.Config.NES_InQuickNES; Global.Config.NES_InQuickNES = false; } } else if (!record && emulator.SystemId == "SNES") // ditto with snes9x vs bsnes { var snes9xName = ((CoreAttributes)Attribute.GetCustomAttribute(typeof(Snes9x), typeof(CoreAttributes))).CoreName; var bsnesName = ((CoreAttributes)Attribute.GetCustomAttribute(typeof(LibsnesCore), typeof(CoreAttributes))).CoreName; if (movie.Core == snes9xName) { PreviousSNES_InSnes9x = Global.Config.SNES_InSnes9x; Global.Config.SNES_InSnes9x = true; } else { PreviousSNES_InSnes9x = Global.Config.SNES_InSnes9x; Global.Config.SNES_InSnes9x = false; } } else if (!record && emulator.SystemId == "GBA") // ditto with GBA, we should probably architect this at some point, this isn't sustainable { var mGBAName = ((CoreAttributes)Attribute.GetCustomAttribute(typeof(MGBAHawk), typeof(CoreAttributes))).CoreName; var vbaNextName = ((CoreAttributes)Attribute.GetCustomAttribute(typeof(VBANext), typeof(CoreAttributes))).CoreName; if (movie.Core == mGBAName) { PreviousGBA_UsemGBA = Global.Config.GBA_UsemGBA; Global.Config.GBA_UsemGBA = true; } else { PreviousSNES_InSnes9x = Global.Config.GBA_UsemGBA; Global.Config.GBA_UsemGBA = false; } } if (record) // This is a hack really, we need to set the movie to its propert state so that it will be considered active later { movie.SwitchToRecord(); } else { movie.SwitchToPlay(); } QueuedMovie = movie; }
private static TestResults StartEmulatorAndRunTests(IProgressReporter progressReporter, IAndroidDebugBridgeFactory adbFactory, ILogger logger, IEmulator droidEmulator, RunAndroidTestsOptions options) { TimeSpan timeout = TimeSpan.FromSeconds(options.EmulatorStartupWaitTimeInSeconds); using (droidEmulator) { progressReporter.ReportStatus("Waiting for emulator to boot."); droidEmulator.Start(timeout).Wait(); var adb = adbFactory.GetAndroidDebugBridge(); var apkPath = options.ApkPath; progressReporter.ReportStatus("Installing tests APK package."); adb.Install(droidEmulator.Device, apkPath, AdbInstallFlags.ReplaceExistingApplication); progressReporter.ReportTestsStarted(options.ApkPackageName); var testRunner = new AndroidTestRunner(logger, adbFactory, droidEmulator.Device, options.ApkPackageName, options.TestInstrumentationClassPath); var testResults = testRunner.RunTests(); progressReporter.ReportTests(testResults); progressReporter.ReportTestsFinished(options.ApkPackageName); return testResults; } }