DS - wire up some screen setting options, the side by side ones don't work because screen arranger has a bug, and it is flawed, going to refactor all of this

This commit is contained in:
adelikat 2020-03-28 12:03:26 -05:00
parent 1647783fa8
commit 730156b5db
5 changed files with 27 additions and 28 deletions

View File

@ -400,9 +400,9 @@ namespace BizHawk.Client.EmuHawk
v = _currentFilterProgram.UntransformPoint("default", v);
// Poop
if (Global.Emulator is MelonDS ds)
if (Global.Emulator is MelonDS ds && ds.TouchScreenStart.HasValue)
{
Point touchLocation = ds.TouchScreenStart;
Point touchLocation = ds.TouchScreenStart.Value;
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

@ -20,7 +20,9 @@ namespace BizHawk.Emulation.Common
public unsafe int[] GenerateFramebuffer(int*[] src, int[] srcLength)
{
if (src.Length != LayoutSettings.Locations.Length)
return null;
{
throw new InvalidCastException("Buffer length mismatch");
}
var ret = new int[LayoutSettings.FinalSize.Width * LayoutSettings.FinalSize.Height];
for (int iBuf = 0; iBuf < src.Length; iBuf++)

View File

@ -119,7 +119,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
}
}
public Point TouchScreenStart => _screenArranger.LayoutSettings.Locations[1];
public Point? TouchScreenStart => _screenArranger.LayoutSettings.Locations.Length > 1
? _screenArranger.LayoutSettings.Locations[1]
: (Point?)null;
/// <summary>
/// MelonDS expects bios and firmware files at a specific location.

View File

@ -42,9 +42,14 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
{
if (_getNewBuffer)
{
// Shenanigans
var buffers = _settings.ScreenOptions.NeedsBottomScreen()
? new[] {GetTopScreenBuffer(), GetBottomScreenBuffer()}
: new[] {GetTopScreenBuffer()};
_getNewBuffer = false;
int*[] buffers = { GetTopScreenBuffer(), GetBottomScreenBuffer() };
int bufferSize = GetScreenBufferSize();
_buffer = _screenArranger.GenerateFramebuffer(buffers, new[] { bufferSize, bufferSize });
}

View File

@ -5,18 +5,22 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
{
public enum VideoScreenOptions
{
Default, TopOnly, BottomOnly, SideBySideLR, SideBySideRL /*, Reverse */
Default, TopOnly, SideBySideLR, SideBySideRL /*, Reverse */
}
public static class VideoScreenOptionExtensions
{
public static bool NeedsBottomScreen(this VideoScreenOptions option)
{
return option != VideoScreenOptions.TopOnly;
}
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
@ -32,37 +36,23 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
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)
Locations = new[] { new Point(0, 0) },
Order = new[] { 0 },
FinalSize = new Size(MelonDS.NativeWidth, MelonDS.NativeHeight)
};
private static ScreenLayoutSettings SideBySideLR => new ScreenLayoutSettings
{
Locations = new[] { new Point(0, 0), new Point(0, MelonDS.NativeHeight) },
Locations = new[] { new Point(0, 0), new Point(MelonDS.NativeWidth, MelonDS.NativeHeight) },
Order = new[] { 0, 1 },
FinalSize = new Size(MelonDS.NativeWidth, MelonDS.NativeHeight * 2)
FinalSize = new Size(MelonDS.NativeWidth * 2, MelonDS.NativeHeight)
};
private static ScreenLayoutSettings SideBySideRL => new ScreenLayoutSettings
{
Locations = new[] { new Point(0, 0), new Point(0, MelonDS.NativeHeight) },
Locations = new[] {new Point(MelonDS.NativeWidth, MelonDS.NativeHeight), new Point(0, 0) },
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)
FinalSize = new Size(MelonDS.NativeWidth * 2, MelonDS.NativeHeight)
};
}
}