support subneshawk for VS menu items, pass dependencies into VSSettings

This commit is contained in:
adelikat 2019-12-15 16:55:40 -06:00
parent 8cc02b8956
commit e84fd17784
4 changed files with 42 additions and 40 deletions

View File

@ -1520,7 +1520,8 @@ namespace BizHawk.Client.EmuHawk
VSControlsMenuItem.Enabled =
VSSettingsMenuItem.Enabled =
Emulator is NES nes && nes.IsVS;
(Emulator is NES nes && nes.IsVS)
|| (Emulator is SubNESHawk sub && sub.IsVs);
NESSoundChannelsMenuItem.Enabled = GlobalWin.Tools.IsAvailable<NESSoundConfig>();
MovieSettingsMenuItem.Enabled = (Emulator is NES || Emulator is SubNESHawk)
@ -1602,7 +1603,12 @@ namespace BizHawk.Client.EmuHawk
{
if (Emulator is NES nes && nes.IsVS)
{
using var form = new NesVsSettings();
using var form = new NesVsSettings(this, nes.GetSyncSettings().Clone());
form.ShowHawkDialog();
}
else if (Emulator is SubNESHawk sub && sub.IsVs)
{
using var form = new NesVsSettings(this, sub.GetSyncSettings().Clone());
form.ShowHawkDialog();
}
}
@ -1618,7 +1624,8 @@ namespace BizHawk.Client.EmuHawk
private void VsInsertCoinP1MenuItem_Click(object sender, EventArgs e)
{
if (Emulator is NES nes && nes.IsVS)
if (Emulator is NES nes && nes.IsVS
|| Emulator is SubNESHawk sub && sub.IsVs)
{
if (!Global.MovieSession.Movie.IsPlaying || Global.MovieSession.Movie.IsFinished)
{
@ -1630,7 +1637,8 @@ namespace BizHawk.Client.EmuHawk
private void VsInsertCoinP2MenuItem_Click(object sender, EventArgs e)
{
if (Emulator is NES nes && nes.IsVS)
if (Emulator is NES nes && nes.IsVS
|| Emulator is SubNESHawk sub && sub.IsVs)
{
if (!Global.MovieSession.Movie.IsPlaying || Global.MovieSession.Movie.IsFinished)
{
@ -1642,7 +1650,8 @@ namespace BizHawk.Client.EmuHawk
private void VsServiceSwitchMenuItem_Click(object sender, EventArgs e)
{
if (Emulator is NES nes && nes.IsVS)
if (Emulator is NES nes && nes.IsVS
|| Emulator is SubNESHawk sub && sub.IsVs)
{
if (!Global.MovieSession.Movie.IsPlaying || Global.MovieSession.Movie.IsFinished)
{

View File

@ -1,26 +1,26 @@
using System;
using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Emulation.Cores.Nintendo.NES;
namespace BizHawk.Client.EmuHawk
{
public partial class NesVsSettings : Form
{
private NES.NESSyncSettings _settings;
private NES _nes;
private readonly MainForm _mainForm;
private readonly NES.NESSyncSettings _settings;
public NesVsSettings()
public NesVsSettings(
MainForm mainForm,
NES.NESSyncSettings syncSettings)
{
_mainForm = mainForm;
_settings = syncSettings;
InitializeComponent();
}
private void NesVsSettings_Load(object sender, EventArgs e)
{
_nes = (NES)Global.Emulator;
_settings = _nes.GetSyncSettings();
Dipswitch1CheckBox.Checked = _settings.VSDipswitches.Dip_Switch_1;
Dipswitch2CheckBox.Checked = _settings.VSDipswitches.Dip_Switch_2;
Dipswitch3CheckBox.Checked = _settings.VSDipswitches.Dip_Switch_3;
@ -42,13 +42,7 @@ namespace BizHawk.Client.EmuHawk
_settings.VSDipswitches.Dip_Switch_7 = Dipswitch7CheckBox.Checked;
_settings.VSDipswitches.Dip_Switch_8 = Dipswitch8CheckBox.Checked;
var changes = _nes.PutSyncSettings(_settings);
if (changes)
{
GlobalWin.MainForm.FlagNeedsReboot();
}
_mainForm.PutCoreSyncSettings(_settings);
Close();
}

View File

@ -76,7 +76,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
static readonly bool USE_DATABASE = true;
public RomStatus RomStatus;
public IEmulatorServiceProvider ServiceProvider { get; private set; }
public IEmulatorServiceProvider ServiceProvider { get; }
private NES()
{
@ -112,19 +112,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
}
}
public bool IsVS
{
get { return _isVS; }
}
public bool IsVS => _isVS;
public bool IsFDS
{
get { return Board is FDS; }
}
public bool IsFDS => Board is FDS;
public CoreComm CoreComm { get; private set; }
public CoreComm CoreComm { get; }
public DisplayType Region { get { return _display_type; } }
public DisplayType Region => _display_type;
public class MyVideoProvider : IVideoProvider
{
@ -223,10 +217,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
}
}
}
public int VirtualWidth { get { return (int)(BufferWidth * 1.146); } }
public int VirtualHeight { get { return BufferHeight; } }
public int BufferWidth { get { return right - left + 1; } }
public int BackgroundColor { get { return 0; } }
public int VirtualWidth => (int)(BufferWidth * 1.146);
public int VirtualHeight => BufferHeight;
public int BufferWidth => right - left + 1;
public int BackgroundColor => 0;
public int BufferHeight
{
get
@ -262,7 +257,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public ControllerDefinition ControllerDefinition { get; private set; }
private int _frame;
public int Frame { get { return _frame; } set { _frame = value; } }
public int Frame { get => _frame;
set => _frame = value;
}
public void ResetCounters()
{
@ -273,11 +270,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public long Timestamp { get; private set; }
public bool DeterministicEmulation { get { return true; } }
public bool DeterministicEmulation => true;
public string SystemId { get { return "NES"; } }
public string SystemId => "NES";
public string GameName { get { return game_name; } }
public string GameName => game_name;
public enum EDetectionOrigin
{

View File

@ -69,7 +69,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk
public int _frame = 0;
public bool IsFDS => subnes.Board is FDS;
public bool IsFDS => subnes.IsFDS;
public bool IsVs => subnes.IsVS;
public bool HasMapperProperties
{