示例#1
0
 public void LoadCartridge(string baseDir, string cartridgeFile)
 {
     SnesApi.LoadRom(cartridgeFile, string.Empty);
     InitDebugger();
     EnableDebugger();
     RunGame();
 }
示例#2
0
        private void StartEmulatorProcess(string baseDir)
        {
            var test = SnesApi.TestDll();

            SnesApi.InitDll();
            //EmuApi.InitDll();
            var version = SnesApi.GetMesenVersion();

            //InteropEmu.SetDisplayLanguage(Brewmaster.Emulation.Language.English);
            //SnesApi.SetDisplayLanguage(Mesen.GUI.Forms.Language.English);


            ApplyVideoConfig();
            SnesApi.InitializeEmu(baseDir, _mainWindow.Handle, _renderControl.Handle, false, false, false);

            ApplyVideoConfig();
            ApplyAudioConfig();
            ApplyInputConfig();
            ApplyEmulationConfig();
            ApplyPreferenceConfig();
            ApplyDebuggerConfig();

            Mesen.GUI.ScreenSize size = SnesApi.GetScreenSize(false);
            _renderControl.Size = new Size(size.Width, size.Height);



            //SnesApi.AddKnownGameFolder(@"C:\Users\dkmrs\Documents\NesDev\sc");

            _notifListener = new NotificationListener();
            _notifListener.OnNotification += HandleNotification;
            //SnesApi.SetNesModel(NesModel.Auto);
            //SnesApi.DebugSetDebuggerConsole(SnesApi.ConsoleId.Master);
        }
示例#3
0
        private void HandleNotification(NotificationEventArgs e)
        {
            switch (e.NotificationType)
            {
            case ConsoleNotificationType.GameLoaded:
                if (!SnesApi.IsPaused())
                {
                    RefreshBreakpoints();
                }
                GameLoaded();
                if (OnRun != null)
                {
                    OnRun();
                }
                if (OnStatusChange != null)
                {
                    OnStatusChange(EmulatorStatus.Playing);
                }
                EmitDebugData();
                break;

            case ConsoleNotificationType.CodeBreak:
                var source = (SnesBreakSource)(byte)e.Parameter.ToInt64();
                //if (source == SnesBreakSource.Breakpoint && OnBreak != null)
                if (OnBreak != null)
                {
                    var state   = SnesDebugApi.GetState();
                    var address = SnesDebugApi.GetAbsoluteAddress(new AddressInfo
                    {
                        Address = (state.Cpu.K << 16) | state.Cpu.PC,
                        Type    = SnesMemoryType.CpuMemory
                    });
                    OnBreak(address.Address);
                }
                if (OnStatusChange != null)
                {
                    OnStatusChange(EmulatorStatus.Paused);
                }
                EmitDebugData();
                break;

            case ConsoleNotificationType.PpuFrameDone:
                CountFrame();
                break;
            }

            if (e.NotificationType == ConsoleNotificationType.PpuFrameDone)
            {
                return;
            }
            if (e.NotificationType == ConsoleNotificationType.EventViewerRefresh)
            {
                return;
            }

            var status = string.Format("Emulator: {0}", e.NotificationType.ToString());

            _logHandler(new LogData(status, LogType.Normal));
        }
示例#4
0
 public void Dispose()
 {
     if (IsRunning())
     {
         SnesApi.Pause();
         Stop();
     }
 }
示例#5
0
        public void SetScale(double scale)
        {
            VideoConfig.VideoScale = scale;
            ApplyVideoConfig();
            ScreenSize size = SnesApi.GetScreenSize(false);

            _renderControl.Size = new Size(size.Width, size.Height);
        }
示例#6
0
 public void Resume()
 {
     if (!IsRunning())
     {
         return;
     }
     SnesApi.Resume();
     if (OnStatusChange != null)
     {
         OnStatusChange(EmulatorStatus.Playing);
     }
 }
示例#7
0
 public void Restart()
 {
     if (!IsRunning())
     {
         return;
     }
     SnesApi.Reset();
     //SnesApi.PowerCycle(); TODO: Would love to make powercycle possible, but causes a weird crash if you stop emulation after a powercycle before running the emulator for a while
     if (OnStatusChange != null)
     {
         OnStatusChange(EmulatorStatus.Playing);
     }
 }
示例#8
0
文件: EmuApi.cs 项目: gouchi/Mesen-S
 public static Image GetSaveStatePreview(string saveStatePath)
 {
     if (File.Exists(saveStatePath))
     {
         byte[] buffer = new byte[512 * 478 * 4];
         Int32  size   = EmuApi.GetSaveStatePreviewWrapper(saveStatePath, buffer);
         if (size > 0)
         {
             Array.Resize(ref buffer, size);
             using (MemoryStream stream = new MemoryStream(buffer)) {
                 return(Image.FromStream(stream));
             }
         }
     }
     return(null);
 }
示例#9
0
 public void Stop()
 {
     if (!IsRunning())
     {
         return;
     }
     Task.Run(() => {
         try
         {
             SnesApi.Stop();
         }
         catch (Exception ex)
         {
             Program.Error("An error occurred while trying to stop the SNES emulator!", ex);
         }
     });
     _isRunning = false;
     if (OnStatusChange != null)
     {
         OnStatusChange(EmulatorStatus.Stopped);
     }
 }
示例#10
0
 public void LoadState(string file)
 {
     SnesApi.LoadStateFile(file);
 }
示例#11
0
 public void SaveState(string file)
 {
     SnesApi.SaveStateFile(file);
 }
示例#12
0
文件: EmuApi.cs 项目: gouchi/Mesen-S
 public static string GetLog()
 {
     return(Utf8Marshaler.PtrToStringUtf8(EmuApi.GetLogWrapper()).Replace("\n", Environment.NewLine));
 }