2019-02-12 22:13:09 -05:00
|
|
|
|
using Mesen.GUI.Config;
|
|
|
|
|
using Mesen.GUI.Debugger;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
2019-02-15 21:33:13 -05:00
|
|
|
|
using System.IO;
|
2019-02-12 22:13:09 -05:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace Mesen.GUI.Forms
|
|
|
|
|
{
|
2019-02-17 19:54:29 -05:00
|
|
|
|
public partial class frmMain : BaseInputForm
|
2019-02-12 22:13:09 -05:00
|
|
|
|
{
|
2019-02-16 08:10:08 -05:00
|
|
|
|
private NotificationListener _notifListener;
|
|
|
|
|
|
2019-02-12 22:13:09 -05:00
|
|
|
|
public frmMain(string[] args)
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
ResourceHelper.LoadResources(Language.English);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnShown(EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnShown(e);
|
|
|
|
|
|
|
|
|
|
EmuApi.InitDll();
|
|
|
|
|
EmuApi.InitializeEmu(ConfigManager.HomeFolder, Handle, ctrlRenderer.Handle, false, false, false);
|
2019-02-16 08:10:08 -05:00
|
|
|
|
|
|
|
|
|
_notifListener = new NotificationListener();
|
|
|
|
|
_notifListener.OnNotification += OnNotificationReceived;
|
2019-02-17 14:42:35 -05:00
|
|
|
|
|
|
|
|
|
new frmLogWindow().Show();
|
2019-02-12 22:13:09 -05:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-16 01:22:31 -05:00
|
|
|
|
protected override void OnFormClosing(FormClosingEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnFormClosing(e);
|
|
|
|
|
|
2019-02-16 08:10:08 -05:00
|
|
|
|
if(_notifListener != null) {
|
|
|
|
|
_notifListener.Dispose();
|
|
|
|
|
_notifListener = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DebugApi.ResumeExecution();
|
2019-02-16 01:22:31 -05:00
|
|
|
|
EmuApi.Stop();
|
|
|
|
|
EmuApi.Release();
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-16 08:10:08 -05:00
|
|
|
|
private void OnNotificationReceived(NotificationEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
switch(e.NotificationType) {
|
|
|
|
|
case ConsoleNotificationType.CodeBreak:
|
|
|
|
|
this.BeginInvoke((Action)(() => {
|
|
|
|
|
DebugWindowManager.OpenDebugWindow(DebugWindow.TraceLogger);
|
|
|
|
|
}));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-12 22:13:09 -05:00
|
|
|
|
private void mnuTraceLogger_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2019-02-16 08:10:08 -05:00
|
|
|
|
DebugWindowManager.OpenDebugWindow(DebugWindow.TraceLogger);
|
2019-02-12 22:13:09 -05:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-15 21:33:13 -05:00
|
|
|
|
private void mnuMemoryTools_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2019-02-16 08:10:08 -05:00
|
|
|
|
DebugWindowManager.OpenDebugWindow(DebugWindow.MemoryTools);
|
2019-02-15 21:33:13 -05:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-12 22:13:09 -05:00
|
|
|
|
private void mnuStep_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
DebugApi.Step(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void mnuOpen_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
using(OpenFileDialog ofd = new OpenFileDialog()) {
|
|
|
|
|
ofd.Filter = ResourceHelper.GetMessage("FilterRom");
|
|
|
|
|
if(ofd.ShowDialog() == DialogResult.OK) {
|
2019-02-15 21:33:13 -05:00
|
|
|
|
LoadFile(ofd.FileName);
|
2019-02-12 22:13:09 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void mnuRun_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
DebugApi.ResumeExecution();
|
|
|
|
|
}
|
2019-02-13 13:32:21 -05:00
|
|
|
|
|
|
|
|
|
private void mnuRun100Instructions_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2019-02-13 23:02:43 -05:00
|
|
|
|
DebugApi.Step(1000);
|
2019-02-13 13:32:21 -05:00
|
|
|
|
}
|
2019-02-15 21:33:13 -05:00
|
|
|
|
|
|
|
|
|
private void LoadFile(string filepath)
|
|
|
|
|
{
|
|
|
|
|
EmuApi.LoadRom(filepath);
|
|
|
|
|
Task.Run(() => {
|
|
|
|
|
EmuApi.Run();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnDragDrop(DragEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnDragDrop(e);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
|
|
|
|
|
if(File.Exists(files[0])) {
|
|
|
|
|
LoadFile(files[0]);
|
|
|
|
|
this.Activate();
|
|
|
|
|
} else {
|
|
|
|
|
//InteropEmu.DisplayMessage("Error", "File not found: " + files[0]);
|
|
|
|
|
}
|
|
|
|
|
} catch(Exception ex) {
|
|
|
|
|
MesenMsgBox.Show("UnexpectedError", MessageBoxButtons.OK, MessageBoxIcon.Error, ex.ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnDragEnter(DragEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnDragEnter(e);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
if(e.Data != null && e.Data.GetDataPresent(DataFormats.FileDrop)) {
|
|
|
|
|
e.Effect = DragDropEffects.Copy;
|
|
|
|
|
} else {
|
|
|
|
|
//InteropEmu.DisplayMessage("Error", "Unsupported operation.");
|
|
|
|
|
}
|
|
|
|
|
} catch(Exception ex) {
|
|
|
|
|
MesenMsgBox.Show("UnexpectedError", MessageBoxButtons.OK, MessageBoxIcon.Error, ex.ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-02-12 22:13:09 -05:00
|
|
|
|
}
|
|
|
|
|
}
|