Exemple #1
0
        void Init(byte[] bios)
        {
            bool GL = SyncSettings.UseGL;

            if (AttachedCore != null)
            {
                AttachedCore.Dispose();
                AttachedCore = null;
            }
            VideoHandle = GCHandle.Alloc(VideoBuffer, GCHandleType.Pinned);
            SoundHandle = GCHandle.Alloc(SoundBuffer, GCHandleType.Pinned);

            LibYabause.CDInterface CDInt = new LibYabause.CDInterface();
            CDInt.InitFunc          = InitH = new LibYabause.CDInterface.Init(CD_Init);
            CDInt.DeInitFunc        = DeInitH = new LibYabause.CDInterface.DeInit(CD_DeInit);
            CDInt.GetStatusFunc     = GetStatusH = new LibYabause.CDInterface.GetStatus(CD_GetStatus);
            CDInt.ReadTOCFunc       = ReadTOCH = new LibYabause.CDInterface.ReadTOC(CD_ReadTOC);
            CDInt.ReadSectorFADFunc = ReadSectorFADH = new LibYabause.CDInterface.ReadSectorFAD(CD_ReadSectorFAD);
            CDInt.ReadAheadFADFunc  = ReadAheadFADH = new LibYabause.CDInterface.ReadAheadFAD(CD_ReadAheadFAD);

            var    fp       = new FilePiping();
            string BiosPipe = fp.GetPipeNameNative();

            fp.Offer(bios);

            int basetime;

            if (SyncSettings.RealTimeRTC)
            {
                basetime = 0;
            }
            else
            {
                basetime = (int)((SyncSettings.RTCInitialTime - new DateTime(1970, 1, 1).ToLocalTime()).TotalSeconds);
            }

            if (!LibYabause.libyabause_init
                (
                    ref CDInt,
                    BiosPipe,
                    GL,
                    SyncSettings.CartType,
                    SyncSettings.SkipBios,
                    !SyncSettings.RealTimeRTC,
                    basetime
                ))
            {
                throw new Exception("libyabause_init() failed!");
            }

            fp.Finish();

            LibYabause.libyabause_setvidbuff(VideoHandle.AddrOfPinnedObject());
            LibYabause.libyabause_setsndbuff(SoundHandle.AddrOfPinnedObject());
            AttachedCore = this;

            // with or without GL, this is the guaranteed frame -1 size; (unless you do a gl resize)
            BufferWidth  = 320;
            BufferHeight = 224;

            InitMemoryDomains();

            GLMode = GL;
            // if in GL mode, this will trigger the initial GL resize
            PutSyncSettings(this.SyncSettings);
        }
Exemple #2
0
		void Init(byte[] bios)
		{
			bool GL = SyncSettings.UseGL;

			if (AttachedCore != null)
			{
				AttachedCore.Dispose();
				AttachedCore = null;
			}
			VideoHandle = GCHandle.Alloc(VideoBuffer, GCHandleType.Pinned);
			SoundHandle = GCHandle.Alloc(SoundBuffer, GCHandleType.Pinned);

			LibYabause.CDInterface CDInt = new LibYabause.CDInterface();
			CDInt.InitFunc = InitH = new LibYabause.CDInterface.Init(CD_Init);
			CDInt.DeInitFunc = DeInitH = new LibYabause.CDInterface.DeInit(CD_DeInit);
			CDInt.GetStatusFunc = GetStatusH = new LibYabause.CDInterface.GetStatus(CD_GetStatus);
			CDInt.ReadTOCFunc = ReadTOCH = new LibYabause.CDInterface.ReadTOC(CD_ReadTOC);
			CDInt.ReadSectorFADFunc = ReadSectorFADH = new LibYabause.CDInterface.ReadSectorFAD(CD_ReadSectorFAD);
			CDInt.ReadAheadFADFunc = ReadAheadFADH = new LibYabause.CDInterface.ReadAheadFAD(CD_ReadAheadFAD);

			var fp = new FilePiping();
			string BiosPipe = fp.GetPipeNameNative();
			fp.Offer(bios);

			int basetime;
			if (SyncSettings.RealTimeRTC)
				basetime = 0;
			else
				basetime = (int)((SyncSettings.RTCInitialTime - new DateTime(1970, 1, 1).ToLocalTime()).TotalSeconds);

			if (!LibYabause.libyabause_init
			(
				ref CDInt,
				BiosPipe,
				GL,
				SyncSettings.CartType,
				SyncSettings.SkipBios,
				!SyncSettings.RealTimeRTC,
				basetime
			))
				throw new Exception("libyabause_init() failed!");

			fp.Finish();

			LibYabause.libyabause_setvidbuff(VideoHandle.AddrOfPinnedObject());
			LibYabause.libyabause_setsndbuff(SoundHandle.AddrOfPinnedObject());
			AttachedCore = this;

			// with or without GL, this is the guaranteed frame -1 size; (unless you do a gl resize)
			BufferWidth = 320;
			BufferHeight = 224;

			InitMemoryDomains();

			GLMode = GL;
			// if in GL mode, this will trigger the initial GL resize
			PutSyncSettings(this.SyncSettings);
		}