Ejemplo n.º 1
0
 public MyGame(IEmulator emulator)
 {
     this.emulator = emulator;
     graphics = new GraphicsDeviceManager(this);
     Content.RootDirectory = "Content";
     IsFixedTimeStep = false;
 }
Ejemplo n.º 2
0
			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>();
				}
			}
Ejemplo n.º 3
0
        public void Execute(IEmulator emulator)
        {
            var debugger = emulator as IDebuggingEmulator;

            if (debugger == null)
                return;

            debugger.DumpMemory();
        }
Ejemplo n.º 4
0
        public void Execute(IEmulator emulator)
        {
            var debugger = emulator as IDebuggingEmulator;

            if (debugger == null)
                return;

            debugger.SetMemoryWatch8(MemoryAddress);
        }
Ejemplo n.º 5
0
 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."
         );
 }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
    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);
    }
Ejemplo n.º 8
0
		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;
		}
Ejemplo n.º 9
0
        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));
            }
        }
Ejemplo n.º 10
0
        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));
            }
        }
Ejemplo n.º 11
0

        
Ejemplo n.º 12
0

        
Ejemplo n.º 13
0

        
Ejemplo n.º 14
0

        
Ejemplo n.º 15
0

        
Ejemplo n.º 16
0

        
Ejemplo n.º 17
0
        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;
 }
Ejemplo n.º 19
0
 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));
        }
Ejemplo n.º 21
0
 public void Execute(IEmulator emulator)
 {
     emulator.Quit();
 }
Ejemplo n.º 22
0

        
Ejemplo n.º 23
0
 public IEnumerable <PadSchema> GetPadSchemas(IEmulator core)
 {
     yield return(StandardController());
 }
Ejemplo n.º 24
0

        
Ejemplo n.º 25
0
 public static bool EnsureCoreIsAccurate(IEmulator emulator)
 {
Ejemplo n.º 26
0
        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();
            }
        }
Ejemplo n.º 27
0

        
Ejemplo n.º 28
0
    /*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;
            }
        };
    }
Ejemplo n.º 29
0

        
Ejemplo n.º 30
0

        
Ejemplo n.º 31
0

        
Ejemplo n.º 32
0

        
Ejemplo n.º 33
0

        
Ejemplo n.º 34
0

        
Ejemplo n.º 35
0
		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;
		}
Ejemplo n.º 36
0

        
Ejemplo n.º 37
0

        
Ejemplo n.º 38
0

        
Ejemplo n.º 39
0

        
Ejemplo n.º 40
0

        
Ejemplo n.º 41
0

        
Ejemplo n.º 42
0

        
Ejemplo n.º 43
0

        
Ejemplo n.º 44
0
		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;
		}
Ejemplo n.º 45
0

        
Ejemplo n.º 46
0

        
Ejemplo n.º 47
0
        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;
            }
        }