DS - refactor settings so that it is an enum that then translates to ScreenArranger settings

This commit is contained in:
adelikat 2020-03-28 11:21:39 -05:00
parent e2ac7d7a8f
commit 3e89a7f201
6 changed files with 80 additions and 22 deletions

View File

@ -402,7 +402,7 @@ namespace BizHawk.Client.EmuHawk
// Poop
if (Global.Emulator is MelonDS ds)
{
Point touchLocation = ds.GetSettings().ScreenOptions.Locations[1];
Point touchLocation = ds.TouchScreenStart;
v.Y = (int)((double)ds.BufferHeight / MelonDS.NativeHeight * (v.Y - touchLocation.Y));
v.X = (int)((double)ds.BufferWidth / MelonDS.NativeWidth * (v.X - touchLocation.X));
}

View File

@ -119,6 +119,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
}
}
public Point TouchScreenStart => _screenArranger.LayoutSettings.Locations[1];
/// <summary>
/// MelonDS expects bios and firmware files at a specific location.
/// This should never be called without an accompanying call to PutSyncSettings.

View File

@ -1,7 +1,6 @@
using System;
using System.Text;
using System.Runtime.InteropServices;
using System.Drawing;
using BizHawk.Emulation.Common;
using Newtonsoft.Json;
@ -10,7 +9,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
{
unsafe partial class MelonDS : ISettable<MelonDS.MelonSettings, MelonDS.MelonSyncSettings>
{
private MelonSettings _settings;
private MelonSettings _settings = new MelonSettings();
public MelonSettings GetSettings()
{
@ -32,21 +31,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
public bool PutSettings(MelonSettings o)
{
if (o?.ScreenOptions == null)
{
o = new MelonSettings
{
ScreenOptions = new ScreenLayoutSettings
{
Locations = new[] { new Point(0, 0), new Point(0, NativeHeight) },
Order = new[] { 0, 1 },
FinalSize = new Size(NativeWidth, NativeHeight * 2)
}
};
}
_settings = o;
_screenArranger.LayoutSettings = _settings.ScreenOptions;
_settings = o ?? new MelonSettings();
_screenArranger.LayoutSettings = _settings.ScreenOptions.ToLayout();
return false;
}
@ -93,7 +79,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
public class MelonSettings
{
public ScreenLayoutSettings ScreenOptions { get; set; }
public VideoScreenOptions ScreenOptions { get; set; } = VideoScreenOptions.Default;
}
public class MelonSyncSettings

View File

@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
using System.Linq;
using System.Runtime.InteropServices;
using BizHawk.Emulation.Common;
@ -16,8 +17,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
public int VirtualWidth => BufferWidth;
public int VirtualHeight => BufferHeight;
public int BufferWidth => _settings.ScreenOptions.FinalSize.Width;
public int BufferHeight => _settings.ScreenOptions.FinalSize.Height;
public int BufferWidth => _screenArranger.LayoutSettings.FinalSize.Width;
public int BufferHeight => _screenArranger.LayoutSettings.FinalSize.Height;
public int VsyncNumerator => 60;

View File

@ -0,0 +1,68 @@
using System.Drawing;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
{
public enum VideoScreenOptions
{
Default, TopOnly, BottomOnly, SideBySideLR, SideBySideRL /*, Reverse */
}
public static class VideoScreenOptionExtensions
{
public static ScreenLayoutSettings ToLayout(this VideoScreenOptions option)
{
return option switch
{
VideoScreenOptions.Default => Default,
VideoScreenOptions.TopOnly => TopOnly,
VideoScreenOptions.BottomOnly => BottomOnly,
VideoScreenOptions.SideBySideLR => SideBySideLR,
VideoScreenOptions.SideBySideRL => SideBySideRL,
_ => Default
};
}
private static ScreenLayoutSettings Default => new ScreenLayoutSettings
{
Locations = new[] { new Point(0, 0), new Point(0, MelonDS.NativeHeight) },
Order = new[] { 0, 1 },
FinalSize = new Size(MelonDS.NativeWidth, MelonDS.NativeHeight * 2)
};
private static ScreenLayoutSettings TopOnly => new ScreenLayoutSettings
{
Locations = new[] { new Point(0, 0), new Point(0, MelonDS.NativeHeight) },
Order = new[] { 0, 1 },
FinalSize = new Size(MelonDS.NativeWidth, MelonDS.NativeHeight * 2)
};
private static ScreenLayoutSettings BottomOnly => new ScreenLayoutSettings
{
Locations = new[] { new Point(0, 0), new Point(0, MelonDS.NativeHeight) },
Order = new[] { 0, 1 },
FinalSize = new Size(MelonDS.NativeWidth, MelonDS.NativeHeight * 2)
};
private static ScreenLayoutSettings SideBySideLR => new ScreenLayoutSettings
{
Locations = new[] { new Point(0, 0), new Point(0, MelonDS.NativeHeight) },
Order = new[] { 0, 1 },
FinalSize = new Size(MelonDS.NativeWidth, MelonDS.NativeHeight * 2)
};
private static ScreenLayoutSettings SideBySideRL => new ScreenLayoutSettings
{
Locations = new[] { new Point(0, 0), new Point(0, MelonDS.NativeHeight) },
Order = new[] { 0, 1 },
FinalSize = new Size(MelonDS.NativeWidth, MelonDS.NativeHeight * 2)
};
private static ScreenLayoutSettings Reverse => new ScreenLayoutSettings
{
Locations = new[] { new Point(0, 0), new Point(0, MelonDS.NativeHeight) },
Order = new[] { 0, 1 },
FinalSize = new Size(MelonDS.NativeWidth, MelonDS.NativeHeight * 2)
};
}
}

View File

@ -109,6 +109,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=PSP/@EntryIndexedValue">PSP</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=PSX/@EntryIndexedValue">PSX</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RAM/@EntryIndexedValue">RAM</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RL/@EntryIndexedValue">RL</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RTC/@EntryIndexedValue">RTC</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SG/@EntryIndexedValue">SG</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SGB/@EntryIndexedValue">SGB</s:String>