예제 #1
0
        public mupen64plusVideoApi(mupen64plusApi core, VideoPluginSettings settings)
        {
            string videoplugin;

            switch (settings.Plugin)
            {
            default:
            case PluginType.Rice:
                videoplugin = "mupen64plus-video-rice.dll";
                break;

            case PluginType.Glide:
                videoplugin = "mupen64plus-video-glide64.dll";
                break;

            case PluginType.GlideMk2:
                videoplugin = "mupen64plus-video-glide64mk2.dll";
                break;

            case PluginType.GLideN64:
                videoplugin = "mupen64plus-video-GLideN64.dll";
                break;
            }

            GfxDll = core.AttachPlugin(mupen64plusApi.m64p_plugin_type.M64PLUGIN_GFX,
                                       videoplugin);
            GFXReadScreen2    = mupen64plusApi.GetTypedDelegate <ReadScreen2>(GfxDll, "ReadScreen2");
            GFXReadScreen2Res = mupen64plusApi.GetTypedDelegate <ReadScreen2Res>(GfxDll, "ReadScreen2");
            var funcPtr = OSTailoredCode.LinkedLibManager.GetProcAddrOrZero(GfxDll, "GetScreenTextureID");

            if (funcPtr != IntPtr.Zero)
            {
                GFXGetScreenTextureID = (GetScreenTextureID)Marshal.GetDelegateForFunctionPointer(funcPtr, typeof(GetScreenTextureID));
            }
        }
예제 #2
0
		public mupen64plusVideoApi(mupen64plusApi core, VideoPluginSettings settings)
		{
			string videoplugin;
			switch (settings.Plugin)
			{
				default:
				case PluginType.Rice:
					videoplugin = "mupen64plus-video-rice.dll";
					break;
				case PluginType.Glide:
					videoplugin = "mupen64plus-video-glide64.dll";
					break;
				case PluginType.GlideMk2:
					videoplugin = "mupen64plus-video-glide64mk2.dll";
					break;
				case PluginType.Jabo:
					videoplugin = "mupen64plus-video-jabo.dll";
					break;
			}

			GfxDll = core.AttachPlugin(mupen64plusApi.m64p_plugin_type.M64PLUGIN_GFX,
				videoplugin);
			GFXReadScreen2 = (ReadScreen2)Marshal.GetDelegateForFunctionPointer(GetProcAddress(GfxDll, "ReadScreen2"), typeof(ReadScreen2));
			GFXReadScreen2Res = (ReadScreen2Res)Marshal.GetDelegateForFunctionPointer(GetProcAddress(GfxDll, "ReadScreen2"), typeof(ReadScreen2Res));
			if(GetProcAddress(GfxDll, "GetScreenTextureID") != IntPtr.Zero)
				GFXGetScreenTextureID = (GetScreenTextureID)Marshal.GetDelegateForFunctionPointer(GetProcAddress(GfxDll, "GetScreenTextureID"), typeof(GetScreenTextureID));
		}
예제 #3
0
        public mupen64plusVideoApi(mupen64plusApi core, VideoPluginSettings settings)
        {
            string videoplugin;

            switch (settings.Plugin)
            {
            default:
            case PluginType.Rice:
                videoplugin = "mupen64plus-video-rice.dll";
                break;

            case PluginType.Glide:
                videoplugin = "mupen64plus-video-glide64.dll";
                break;

            case PluginType.GlideMk2:
                videoplugin = "mupen64plus-video-glide64mk2.dll";
                break;

            case PluginType.Jabo:
                videoplugin = "mupen64plus-video-jabo.dll";
                break;
            }

            GfxDll = core.AttachPlugin(mupen64plusApi.m64p_plugin_type.M64PLUGIN_GFX,
                                       videoplugin);
            GFXReadScreen2    = (ReadScreen2)Marshal.GetDelegateForFunctionPointer(GetProcAddress(GfxDll, "ReadScreen2"), typeof(ReadScreen2));
            GFXReadScreen2Res = (ReadScreen2Res)Marshal.GetDelegateForFunctionPointer(GetProcAddress(GfxDll, "ReadScreen2"), typeof(ReadScreen2Res));
            if (GetProcAddress(GfxDll, "GetScreenTextureID") != IntPtr.Zero)
            {
                GFXGetScreenTextureID = (GetScreenTextureID)Marshal.GetDelegateForFunctionPointer(GetProcAddress(GfxDll, "GetScreenTextureID"), typeof(GetScreenTextureID));
            }
        }
예제 #4
0
		/// <summary>
		/// Loads native functions and attaches itself to the core
		/// </summary>
		/// <param name="core">Core with loaded core api</param>
		public mupen64plusAudioApi(mupen64plusApi core)
		{
			AudDll = core.AttachPlugin(mupen64plusApi.m64p_plugin_type.M64PLUGIN_AUDIO,
				"mupen64plus-audio-bkm.dll");

			// Connect dll functions
			dllGetBufferSize = (GetBufferSize)Marshal.GetDelegateForFunctionPointer(GetProcAddress(AudDll, "GetBufferSize"), typeof(GetBufferSize));
			dllReadAudioBuffer = (ReadAudioBuffer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(AudDll, "ReadAudioBuffer"), typeof(ReadAudioBuffer));
			dllGetAudioRate = (GetAudioRate)Marshal.GetDelegateForFunctionPointer(GetProcAddress(AudDll, "GetAudioRate"), typeof(GetAudioRate));
		}
예제 #5
0
		/// <summary>
		/// Creates a N64 Audio subsystem
		/// </summary>
		/// <param name="api">Mupen64 api which is used for fetching sound</param>
		public N64Audio(mupen64plusApi core)
		{
			this.api = new mupen64plusAudioApi(core);

			_samplingRate = api.GetSamplingRate();
			Resampler = new SpeexResampler(6, SamplingRate, 44100,
				SamplingRate, 44100);

			core.VInterrupt += DoAudioFrame;
		}
예제 #6
0
        /// <summary>
        /// Loads native functions and attaches itself to the core
        /// </summary>
        /// <param name="core">Core with loaded core api</param>
        public mupen64plusAudioApi(mupen64plusApi core)
        {
            AudDll = core.AttachPlugin(mupen64plusApi.m64p_plugin_type.M64PLUGIN_AUDIO,
                                       "mupen64plus-audio-bkm.dll");

            // Connect dll functions
            dllGetBufferSize   = (GetBufferSize)Marshal.GetDelegateForFunctionPointer(GetProcAddress(AudDll, "GetBufferSize"), typeof(GetBufferSize));
            dllReadAudioBuffer = (ReadAudioBuffer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(AudDll, "ReadAudioBuffer"), typeof(ReadAudioBuffer));
            dllGetAudioRate    = (GetAudioRate)Marshal.GetDelegateForFunctionPointer(GetProcAddress(AudDll, "GetAudioRate"), typeof(GetAudioRate));
        }
예제 #7
0
        public mupen64plusInputApi(mupen64plusApi core)
        {
            T GetInputDelegate <T>(string proc) where T : Delegate => mupen64plusApi.GetTypedDelegate <T>(InpDll, proc);

            InpDll = core.AttachPlugin(mupen64plusApi.m64p_plugin_type.M64PLUGIN_INPUT,
                                       "mupen64plus-input-bkm.dll");

            InpSetInputCallback       = GetInputDelegate <SetInputCallback>("SetInputCallback");
            InpSetRumbleCallback      = GetInputDelegate <SetRumbleCallback>("SetRumbleCallback");
            InpSetControllerPakType   = GetInputDelegate <SetControllerPakType>("SetControllerPakType");
            InpSetControllerConnected = GetInputDelegate <SetControllerConnected>("SetControllerConnected");
        }
예제 #8
0
        /// <summary>
        /// Loads native functions and attaches itself to the core
        /// </summary>
        /// <param name="core">Core with loaded core api</param>
        public mupen64plusAudioApi(mupen64plusApi core)
        {
            T GetAudioDelegate <T>(string proc) where T : Delegate => mupen64plusApi.GetTypedDelegate <T>(AudDll, proc);

            AudDll = core.AttachPlugin(mupen64plusApi.m64p_plugin_type.M64PLUGIN_AUDIO,
                                       "mupen64plus-audio-bkm.dll");

            // Connect dll functions
            dllGetBufferSize   = GetAudioDelegate <GetBufferSize>("GetBufferSize");
            dllReadAudioBuffer = GetAudioDelegate <ReadAudioBuffer>("ReadAudioBuffer");
            dllGetAudioRate    = GetAudioDelegate <GetAudioRate>("GetAudioRate");
        }
예제 #9
0
		public mupen64plusInputApi(mupen64plusApi core)
		{
			InpDll = core.AttachPlugin(mupen64plusApi.m64p_plugin_type.M64PLUGIN_INPUT,
				"mupen64plus-input-bkm.dll");

			mupen64plusApi.m64p_error result;
			InpSetInputCallback = (SetInputCallback)Marshal.GetDelegateForFunctionPointer(GetProcAddress(InpDll, "SetInputCallback"), typeof(SetInputCallback));
			InpSetRumbleCallback = (SetRumbleCallback)Marshal.GetDelegateForFunctionPointer(GetProcAddress(InpDll, "SetRumbleCallback"), typeof(SetRumbleCallback));
			InpSetControllerPakType = (SetControllerPakType)Marshal.GetDelegateForFunctionPointer(GetProcAddress(InpDll, "SetControllerPakType"), typeof(SetControllerPakType));
			InpSetControllerConnected = (SetControllerConnected)Marshal.GetDelegateForFunctionPointer(GetProcAddress(InpDll, "SetControllerConnected"), typeof(SetControllerConnected));

			m64pRumbleCallback = new RumbleCallback(FireOnRumbleChange);
			result = InpSetRumbleCallback(m64pRumbleCallback);
		}
예제 #10
0
		public N64Input(mupen64plusApi core, CoreComm comm, N64SyncSettings.N64ControllerSettings[] controllerSettings)
		{
			api = new mupen64plusInputApi(core);
			CoreComm = comm;

			api.SetM64PInputCallback(new mupen64plusInputApi.InputCallback(GetControllerInput));

			core.VInterrupt += ShiftInputPolledBools;
			for (int i = 0; i < controllerSettings.Length; ++i)
			{
				SetControllerConnected(i, controllerSettings[i].IsConnected);
				SetControllerPakType(i, controllerSettings[i].PakType);
			}
		}
예제 #11
0
        public mupen64plusInputApi(mupen64plusApi core)
        {
            InpDll = core.AttachPlugin(mupen64plusApi.m64p_plugin_type.M64PLUGIN_INPUT,
                                       "mupen64plus-input-bkm.dll");

            mupen64plusApi.m64p_error result;
            InpSetInputCallback       = (SetInputCallback)Marshal.GetDelegateForFunctionPointer(GetProcAddress(InpDll, "SetInputCallback"), typeof(SetInputCallback));
            InpSetRumbleCallback      = (SetRumbleCallback)Marshal.GetDelegateForFunctionPointer(GetProcAddress(InpDll, "SetRumbleCallback"), typeof(SetRumbleCallback));
            InpSetControllerPakType   = (SetControllerPakType)Marshal.GetDelegateForFunctionPointer(GetProcAddress(InpDll, "SetControllerPakType"), typeof(SetControllerPakType));
            InpSetControllerConnected = (SetControllerConnected)Marshal.GetDelegateForFunctionPointer(GetProcAddress(InpDll, "SetControllerConnected"), typeof(SetControllerConnected));

            m64pRumbleCallback = new RumbleCallback(FireOnRumbleChange);
            result             = InpSetRumbleCallback(m64pRumbleCallback);
        }
예제 #12
0
		/// <summary>
		/// Creates N64 Video system with mupen64plus backend
		/// </summary>
		/// <param name="api">mupen64plus DLL that is used</param>
		public N64VideoProvider(mupen64plusApi core, VideoPluginSettings videosettings)
		{
			this.api = new mupen64plusVideoApi(core, videosettings);
			int width = 0;
			int height = 0;
			api.GetScreenDimensions(ref width, ref height);
			
			SetBufferSize(
				width > videosettings.Width ? width : videosettings.Width,
				height > videosettings.Height ? height : videosettings.Height
			);

			core.BeforeRender += DoVideoFrame;
			core.BeforeRender += () => { IsVIFrame = true; };
		}
예제 #13
0
        public mupen64plusVideoApi(mupen64plusApi core, VideoPluginSettings settings)
        {
            string videoplugin;

            //bool jaboReady = false;
            switch (settings.Plugin)
            {
            default:
            case PluginType.Rice:
                videoplugin = "mupen64plus-video-rice.dll";
                break;

            case PluginType.Glide:
                videoplugin = "mupen64plus-video-glide64.dll";
                break;

            case PluginType.GlideMk2:
                videoplugin = "mupen64plus-video-glide64mk2.dll";
                break;

            case PluginType.Jabo:
                videoplugin = "mupen64plus-video-jabo.dll";

                N64JaboManager manager = new N64JaboManager();
                manager.Scan();
                if (manager.Status == N64JaboManager.JaboStatus.ReadyToPatch)
                {
                    manager.Patch();
                }
                if (manager.Status != N64JaboManager.JaboStatus.Ready)
                {
                    throw new FileNotFoundException(string.Format("Error: Jabo dll was not found. please copy Jabo_Direct3D8.dll from a Project64 v1.6.1 installation into Bizhawk's dll directory."));
                }

                break;
            }

            GfxDll = core.AttachPlugin(mupen64plusApi.m64p_plugin_type.M64PLUGIN_GFX,
                                       videoplugin);
            GFXReadScreen2    = (ReadScreen2)Marshal.GetDelegateForFunctionPointer(GetProcAddress(GfxDll, "ReadScreen2"), typeof(ReadScreen2));
            GFXReadScreen2Res = (ReadScreen2Res)Marshal.GetDelegateForFunctionPointer(GetProcAddress(GfxDll, "ReadScreen2"), typeof(ReadScreen2Res));
            if (GetProcAddress(GfxDll, "GetScreenTextureID") != IntPtr.Zero)
            {
                GFXGetScreenTextureID = (GetScreenTextureID)Marshal.GetDelegateForFunctionPointer(GetProcAddress(GfxDll, "GetScreenTextureID"), typeof(GetScreenTextureID));
            }
        }
예제 #14
0
		public mupen64plusVideoApi(mupen64plusApi core, VideoPluginSettings settings)
		{
			string videoplugin;
			//bool jaboReady = false;
			switch (settings.Plugin)
			{
				default:
				case PluginType.Rice:
					videoplugin = "mupen64plus-video-rice.dll";
					break;
				case PluginType.Glide:
					videoplugin = "mupen64plus-video-glide64.dll";
					break;
				case PluginType.GlideMk2:
					videoplugin = "mupen64plus-video-glide64mk2.dll";
					break;
				case PluginType.Jabo:
					videoplugin = "mupen64plus-video-jabo.dll";

					N64JaboManager manager = new N64JaboManager();
					manager.Scan();
					if (manager.Status == N64JaboManager.JaboStatus.ReadyToPatch)
						manager.Patch();
					if(manager.Status != N64JaboManager.JaboStatus.Ready)
						throw new FileNotFoundException(string.Format("Error: Jabo dll was not found. please copy Jabo_Direct3D8.dll from a Project64 v1.6.1 installation into Bizhawk's dll directory."));

					break;
			}

			GfxDll = core.AttachPlugin(mupen64plusApi.m64p_plugin_type.M64PLUGIN_GFX,
				videoplugin);
			GFXReadScreen2 = (ReadScreen2)Marshal.GetDelegateForFunctionPointer(GetProcAddress(GfxDll, "ReadScreen2"), typeof(ReadScreen2));
			GFXReadScreen2Res = (ReadScreen2Res)Marshal.GetDelegateForFunctionPointer(GetProcAddress(GfxDll, "ReadScreen2"), typeof(ReadScreen2Res));
			if(GetProcAddress(GfxDll, "GetScreenTextureID") != IntPtr.Zero)
				GFXGetScreenTextureID = (GetScreenTextureID)Marshal.GetDelegateForFunctionPointer(GetProcAddress(GfxDll, "GetScreenTextureID"), typeof(GetScreenTextureID));
		}
예제 #15
0
파일: N64.cs 프로젝트: ddugovic/RASuite
		/// <summary>
		/// Create mupen64plus Emulator
		/// </summary>
		/// <param name="comm">Core communication object</param>
		/// <param name="game">Game information of game to load</param>
		/// <param name="rom">Rom that should be loaded</param>
		/// <param name="SyncSettings">N64SyncSettings object</param>
		public N64(CoreComm comm, GameInfo game, byte[] rom, object settings, object syncSettings)
		{
			int SaveType = 0;
			if (game.OptionValue("SaveType") == "EEPROM_16K")
			{
				SaveType = 1;
			}

			CoreComm = comm;

			_syncSettings = (N64SyncSettings)syncSettings ?? new N64SyncSettings();
			_settings = (N64Settings)settings ?? new N64Settings();

			byte country_code = rom[0x3E];
			switch (country_code)
			{
				// PAL codes
				case 0x44:
				case 0x46:
				case 0x49:
				case 0x50:
				case 0x53:
				case 0x55:
				case 0x58:
				case 0x59:
					_display_type = DisplayType.PAL;
					break;

				// NTSC codes
				case 0x37:
				case 0x41:
				case 0x45:
				case 0x4a:
				default: // Fallback for unknown codes
					_display_type = DisplayType.NTSC;
					break;
			}
			switch (DisplayType)
			{
				case DisplayType.NTSC:
					comm.VsyncNum = 60000;
					comm.VsyncDen = 1001;
					break;
				default:
					comm.VsyncNum = 50;
					comm.VsyncDen = 1;
					break;
			}

			StartThreadLoop();

			var videosettings = _syncSettings.GetVPS(game, _settings.VideoSizeX, _settings.VideoSizeY);
			var coreType = _syncSettings.Core;

			//zero 19-apr-2014 - added this to solve problem with SDL initialization corrupting the main thread (I think) and breaking subsequent emulators (for example, NES)
			//not sure why this works... if we put the plugin initializations in here, we get deadlocks in some SDL initialization. doesnt make sense to me...
			RunThreadAction(() =>
			{
				api = new mupen64plusApi(this, rom, videosettings, SaveType, (int)coreType);
			});

			// Order is important because the register with the mupen core
			_videoProvider = new N64VideoProvider(api, videosettings);
			_audioProvider = new N64Audio(api);
			_inputProvider = new N64Input(api, comm, this._syncSettings.Controllers);


			string rsp = _syncSettings.Rsp == N64SyncSettings.RspType.Rsp_Hle ?
				"mupen64plus-rsp-hle.dll" :
				"mupen64plus-rsp-z64-hlevideo.dll";

			api.AttachPlugin(mupen64plusApi.m64p_plugin_type.M64PLUGIN_RSP, rsp);

			InitMemoryDomains();
			RefreshMemoryCallbacks();

			api.AsyncExecuteEmulator();
			SetControllerButtons();
		}
        public mupen64plusApi(N64 bizhawkCore, byte[] rom, VideoPluginSettings video_settings, int SaveType, int CoreType, bool DisableExpansionSlot)
        {
            // There can only be one core (otherwise breaks mupen64plus)
            if (AttachedCore != null)
            {
                AttachedCore.Dispose();
                AttachedCore = null;
            }
            this.bizhawkCore = bizhawkCore;

            CoreDll = LoadLibrary("mupen64plus.dll");
            if (CoreDll == IntPtr.Zero)
            {
                throw new InvalidOperationException(string.Format("Failed to load mupen64plus.dll"));
            }

            connectFunctionPointers();

            // Start up the core
            m64p_error result = m64pCoreStartup(0x20001, "", "", "Core",
                                                null, "", IntPtr.Zero);

            // Open the core settings section in the config system
            IntPtr core_section = IntPtr.Zero;

            m64pConfigOpenSection("Core", ref core_section);

            // Set the savetype if needed
            if (DisableExpansionSlot)
            {
                int disable = 1;
                m64pConfigSetParameter(core_section, "DisableExtraMem", m64p_type.M64TYPE_INT, ref disable);
            }

            // Set the savetype if needed
            if (SaveType != 0)
            {
                m64pConfigSetParameter(core_section, "SaveType", m64p_type.M64TYPE_INT, ref SaveType);
            }

            m64pConfigSetParameter(core_section, "R4300Emulator", m64p_type.M64TYPE_INT, ref CoreType);

            // Pass the rom to the core
            result = m64pCoreDoCommandByteArray(m64p_command.M64CMD_ROM_OPEN, rom.Length, rom);

            // Open the general video settings section in the config system
            IntPtr video_section = IntPtr.Zero;

            m64pConfigOpenSection("Video-General", ref video_section);

            // Set the desired width and height for mupen64plus
            result = m64pConfigSetParameter(video_section, "ScreenWidth", m64p_type.M64TYPE_INT, ref video_settings.Width);
            result = m64pConfigSetParameter(video_section, "ScreenHeight", m64p_type.M64TYPE_INT, ref video_settings.Height);

            set_video_parameters(video_settings);

            InitSaveram();

            // Initialize event invoker
            m64pFrameCallback  = new FrameCallback(FireFrameFinishedEvent);
            result             = m64pCoreDoCommandFrameCallback(m64p_command.M64CMD_SET_FRAME_CALLBACK, 0, m64pFrameCallback);
            m64pVICallback     = new VICallback(FireVIEvent);
            result             = m64pCoreDoCommandVICallback(m64p_command.M64CMD_SET_VI_CALLBACK, 0, m64pVICallback);
            m64pRenderCallback = new RenderCallback(FireRenderEvent);
            result             = m64pCoreDoCommandRenderCallback(m64p_command.M64CMD_SET_RENDER_CALLBACK, 0, m64pRenderCallback);

            // Prepare to start the emulator in a different thread
            m64pEmulator = new Thread(ExecuteEmulator);

            AttachedCore = this;
        }
예제 #17
0
		public mupen64plusApi(N64 bizhawkCore, byte[] rom, VideoPluginSettings video_settings, int SaveType, int CoreType, bool DisableExpansionSlot)
		{
			// There can only be one core (otherwise breaks mupen64plus)
			if (AttachedCore != null)
			{
				AttachedCore.Dispose();
				AttachedCore = null;
			}
			this.bizhawkCore = bizhawkCore;

			CoreDll = LoadLibrary("mupen64plus.dll");
			if (CoreDll == IntPtr.Zero)
				throw new InvalidOperationException(string.Format("Failed to load mupen64plus.dll"));

			connectFunctionPointers();

			// Start up the core
			m64p_error result = m64pCoreStartup(0x20001, "", "", "Core",
				null, "", IntPtr.Zero);

			// Set the savetype if needed
			if (DisableExpansionSlot)
			{
				IntPtr core_section = IntPtr.Zero;
				int disable = 1;
				m64pConfigOpenSection("Core", ref core_section);
				m64pConfigSetParameter(core_section, "DisableExtraMem", m64p_type.M64TYPE_INT, ref disable);
			}

			// Set the savetype if needed
			if (SaveType != 0)
			{
				IntPtr core_section = IntPtr.Zero;
				m64pConfigOpenSection("Core", ref core_section);
				m64pConfigSetParameter(core_section, "SaveType", m64p_type.M64TYPE_INT, ref SaveType);
			}

			IntPtr coreSection = IntPtr.Zero;
			m64pConfigOpenSection("Core", ref coreSection);
			m64pConfigSetParameter(coreSection, "R4300Emulator", m64p_type.M64TYPE_INT, ref CoreType);

			// Pass the rom to the core
			result = m64pCoreDoCommandByteArray(m64p_command.M64CMD_ROM_OPEN, rom.Length, rom);

			// Open the general video settings section in the config system
			IntPtr video_section = IntPtr.Zero;
			m64pConfigOpenSection("Video-General", ref video_section);

			// Set the desired width and height for mupen64plus
			result = m64pConfigSetParameter(video_section, "ScreenWidth", m64p_type.M64TYPE_INT, ref video_settings.Width);
			result = m64pConfigSetParameter(video_section, "ScreenHeight", m64p_type.M64TYPE_INT, ref video_settings.Height);

			set_video_parameters(video_settings);

			InitSaveram();

			// Initialize event invoker
			m64pFrameCallback = new FrameCallback(FireFrameFinishedEvent);
			result = m64pCoreDoCommandFrameCallback(m64p_command.M64CMD_SET_FRAME_CALLBACK, 0, m64pFrameCallback);
			m64pVICallback = new VICallback(FireVIEvent);
			result = m64pCoreDoCommandVICallback(m64p_command.M64CMD_SET_VI_CALLBACK, 0, m64pVICallback);
			m64pRenderCallback = new RenderCallback(FireRenderEvent);
			result = m64pCoreDoCommandRenderCallback(m64p_command.M64CMD_SET_RENDER_CALLBACK, 0, m64pRenderCallback);

			// Prepare to start the emulator in a different thread
			m64pEmulator = new Thread(ExecuteEmulator);

			AttachedCore = this;
		}
예제 #18
0
파일: N64.cs 프로젝트: ddugovic/RASuite
		private MemoryDomain MakeMemoryDomain(string name, mupen64plusApi.N64_MEMORY id, MemoryDomain.Endian endian)
		{
			int size = api.get_memory_size(id);

			//if this type of memory isnt available, dont make the memory domain
			if (size == 0)
			{
				return null;
			}

			IntPtr memPtr = api.get_memory_ptr(id);

			var md = new MemoryDomain(
				name,
				size,
				endian,
				delegate(int addr)
				{
					if (addr < 0 || addr >= size)
					{
						throw new ArgumentOutOfRangeException();
					}

					return Marshal.ReadByte(memPtr, addr);
				},
				delegate(int addr, byte val)
				{
					if (addr < 0 || addr >= size)
					{
						throw new ArgumentOutOfRangeException();
					}

					Marshal.WriteByte(memPtr + addr, val);
				});

			_memoryDomains.Add(md);

			return md;
		}
예제 #19
0
        private void MakeMemoryDomain(string name, mupen64plusApi.N64_MEMORY id, MemoryDomain.Endian endian, bool swizzled = false)
        {
            int size = api.get_memory_size(id);

            //if this type of memory isnt available, dont make the memory domain
            if (size == 0)
            {
                return;
            }

            IntPtr memPtr = api.get_memory_ptr(id);

            Func<long, byte> peekByte;
            Action<long, byte> pokeByte;

            if (swizzled)
            {
                peekByte = delegate(long addr)
                {
                    if (addr < 0 || addr >= size)
                    {
                        throw new ArgumentOutOfRangeException();
                    }

                    return Marshal.ReadByte(memPtr, (int)(addr ^ 3));
                };
                pokeByte = delegate(long addr, byte val)
                {
                    if (addr < 0 || addr >= size)
                    {
                        throw new ArgumentOutOfRangeException();
                    }

                    Marshal.WriteByte(memPtr, (int)(addr ^ 3), val);
                };
            }
            else
            {
                peekByte = delegate(long addr)
                {
                    if (addr < 0 || addr >= size)
                    {
                        throw new ArgumentOutOfRangeException();
                    }

                    return Marshal.ReadByte(memPtr, (int)(addr));
                };
                pokeByte = delegate(long addr, byte val)
                {
                    if (addr < 0 || addr >= size)
                    {
                        throw new ArgumentOutOfRangeException();
                    }

                    Marshal.WriteByte(memPtr, (int)(addr), val);
                };
            }

            var md = new MemoryDomainDelegate(name, size, endian, peekByte, pokeByte, 4);

            _memoryDomains.Add(md);
        }