2015-07-17 21:18:57 -04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Drawing.Imaging;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Mesen.GUI.Config
|
|
|
|
|
{
|
|
|
|
|
public class VideoInfo
|
|
|
|
|
{
|
|
|
|
|
public bool ShowFPS = false;
|
2017-03-19 13:05:33 -04:00
|
|
|
|
[MinMax(0, 100)] public UInt32 OverscanLeft = 0;
|
|
|
|
|
[MinMax(0, 100)] public UInt32 OverscanRight = 0;
|
|
|
|
|
[MinMax(0, 100)] public UInt32 OverscanTop = 8;
|
|
|
|
|
[MinMax(0, 100)] public UInt32 OverscanBottom = 8;
|
|
|
|
|
[MinMax(0.1, 10.0)] public double VideoScale = 2;
|
2016-01-05 21:28:38 -05:00
|
|
|
|
public VideoFilterType VideoFilter = VideoFilterType.None;
|
2016-05-24 19:45:58 -04:00
|
|
|
|
public bool UseBilinearInterpolation = false;
|
2017-07-23 14:00:13 -04:00
|
|
|
|
public VideoAspectRatio AspectRatio = VideoAspectRatio.NoStretching;
|
2017-11-11 20:55:33 -05:00
|
|
|
|
public ScreenRotation ScreenRotation = ScreenRotation.None;
|
2017-03-19 13:05:33 -04:00
|
|
|
|
[MinMax(0.1, 5.0)] public double CustomAspectRatio = 1.0;
|
2016-05-19 18:55:05 -04:00
|
|
|
|
public bool VerticalSync = false;
|
2016-01-16 09:50:33 -05:00
|
|
|
|
public bool UseHdPacks = false;
|
2017-09-29 22:09:00 -04:00
|
|
|
|
public bool IntegerFpsMode = false;
|
2016-05-27 17:19:23 -04:00
|
|
|
|
public string PaletteData;
|
2015-07-17 21:18:57 -04:00
|
|
|
|
|
2017-03-19 13:05:33 -04:00
|
|
|
|
[MinMax(-100, 100)] public Int32 Brightness = 0;
|
|
|
|
|
[MinMax(-100, 100)] public Int32 Contrast = 0;
|
|
|
|
|
[MinMax(-100, 100)] public Int32 Hue = 0;
|
|
|
|
|
[MinMax(-100, 100)] public Int32 Saturation = 0;
|
|
|
|
|
[MinMax(0, 100)] public Int32 ScanlineIntensity = 0;
|
|
|
|
|
|
|
|
|
|
[MinMax(-100, 100)] public Int32 NtscArtifacts = 0;
|
|
|
|
|
[MinMax(-100, 100)] public Int32 NtscBleed = 0;
|
|
|
|
|
[MinMax(-100, 100)] public Int32 NtscFringing = 0;
|
|
|
|
|
[MinMax(-100, 100)] public Int32 NtscGamma = 0;
|
|
|
|
|
[MinMax(-100, 100)] public Int32 NtscResolution = 0;
|
|
|
|
|
[MinMax(-100, 100)] public Int32 NtscSharpness = 0;
|
2016-05-26 22:32:20 -04:00
|
|
|
|
public bool NtscMergeFields = false;
|
2018-01-07 15:52:05 -05:00
|
|
|
|
public bool NtscVerticalBlend = true;
|
2016-05-26 22:32:20 -04:00
|
|
|
|
|
2017-03-19 13:05:33 -04:00
|
|
|
|
[MinMax(-50, 400)] public Int32 NtscYFilterLength = 0;
|
|
|
|
|
[MinMax(0, 400)] public Int32 NtscIFilterLength = 50;
|
|
|
|
|
[MinMax(0, 400)] public Int32 NtscQFilterLength = 50;
|
2016-12-27 15:04:20 -05:00
|
|
|
|
|
2016-09-11 11:03:26 -04:00
|
|
|
|
public bool DisableBackground = false;
|
|
|
|
|
public bool DisableSprites = false;
|
2016-10-23 13:29:37 -04:00
|
|
|
|
public bool ForceBackgroundFirstColumn = false;
|
|
|
|
|
public bool ForceSpritesFirstColumn = false;
|
2016-09-11 11:03:26 -04:00
|
|
|
|
|
2017-08-03 21:55:31 -04:00
|
|
|
|
public bool FullscreenForceIntegerScale = false;
|
2017-11-29 23:24:26 -05:00
|
|
|
|
public bool UseExclusiveFullscreen = false;
|
2017-12-28 10:59:27 -05:00
|
|
|
|
public VideoRefreshRates ExclusiveFullscreenRefreshRate = VideoRefreshRates._60;
|
2017-08-03 21:55:31 -04:00
|
|
|
|
|
2017-05-22 18:22:26 -04:00
|
|
|
|
public bool UseCustomVsPalette = false;
|
2017-08-12 22:21:16 -04:00
|
|
|
|
public bool ShowColorIndexes = true;
|
2017-05-22 18:22:26 -04:00
|
|
|
|
|
2016-05-27 17:19:23 -04:00
|
|
|
|
public List<PaletteInfo> SavedPalettes = new List<PaletteInfo>();
|
|
|
|
|
|
2015-07-17 21:18:57 -04:00
|
|
|
|
public VideoInfo()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static public void ApplyConfig()
|
|
|
|
|
{
|
2015-07-23 23:16:31 -04:00
|
|
|
|
VideoInfo videoInfo = ConfigManager.Config.VideoInfo;
|
2015-08-24 20:27:07 -04:00
|
|
|
|
|
2016-01-06 23:10:29 -05:00
|
|
|
|
InteropEmu.SetFlag(EmulationFlags.ShowFPS, videoInfo.ShowFPS);
|
|
|
|
|
InteropEmu.SetFlag(EmulationFlags.VerticalSync, videoInfo.VerticalSync);
|
2016-01-16 09:50:33 -05:00
|
|
|
|
InteropEmu.SetFlag(EmulationFlags.UseHdPacks, videoInfo.UseHdPacks);
|
2017-09-29 22:09:00 -04:00
|
|
|
|
InteropEmu.SetFlag(EmulationFlags.IntegerFpsMode, videoInfo.IntegerFpsMode);
|
2015-07-23 23:16:31 -04:00
|
|
|
|
|
2016-09-11 11:03:26 -04:00
|
|
|
|
InteropEmu.SetFlag(EmulationFlags.DisableBackground, videoInfo.DisableBackground);
|
|
|
|
|
InteropEmu.SetFlag(EmulationFlags.DisableSprites, videoInfo.DisableSprites);
|
2016-10-23 13:29:37 -04:00
|
|
|
|
InteropEmu.SetFlag(EmulationFlags.ForceBackgroundFirstColumn, videoInfo.ForceBackgroundFirstColumn);
|
|
|
|
|
InteropEmu.SetFlag(EmulationFlags.ForceSpritesFirstColumn, videoInfo.ForceSpritesFirstColumn);
|
2016-09-11 11:03:26 -04:00
|
|
|
|
|
2017-05-22 18:22:26 -04:00
|
|
|
|
InteropEmu.SetFlag(EmulationFlags.UseCustomVsPalette, videoInfo.UseCustomVsPalette);
|
|
|
|
|
|
2015-07-23 23:16:31 -04:00
|
|
|
|
InteropEmu.SetOverscanDimensions(videoInfo.OverscanLeft, videoInfo.OverscanRight, videoInfo.OverscanTop, videoInfo.OverscanBottom);
|
|
|
|
|
|
2017-11-11 20:55:33 -05:00
|
|
|
|
InteropEmu.SetScreenRotation((UInt32)videoInfo.ScreenRotation);
|
|
|
|
|
|
2017-12-28 10:59:27 -05:00
|
|
|
|
InteropEmu.SetExclusiveRefreshRate((UInt32)videoInfo.ExclusiveFullscreenRefreshRate);
|
|
|
|
|
|
2016-01-05 21:28:38 -05:00
|
|
|
|
InteropEmu.SetVideoFilter(videoInfo.VideoFilter);
|
2016-05-24 19:45:58 -04:00
|
|
|
|
InteropEmu.SetVideoResizeFilter(videoInfo.UseBilinearInterpolation ? VideoResizeFilter.Bilinear : VideoResizeFilter.NearestNeighbor);
|
2017-05-01 23:05:31 -04:00
|
|
|
|
InteropEmu.SetVideoScale(videoInfo.VideoScale <= 10 ? videoInfo.VideoScale : 2);
|
2017-02-18 13:41:16 -05:00
|
|
|
|
InteropEmu.SetVideoAspectRatio(videoInfo.AspectRatio, videoInfo.CustomAspectRatio);
|
2016-01-17 14:21:31 -05:00
|
|
|
|
|
2016-05-26 22:32:20 -04:00
|
|
|
|
InteropEmu.SetPictureSettings(videoInfo.Brightness / 100.0, videoInfo.Contrast / 100.0, videoInfo.Saturation / 100.0, videoInfo.Hue / 100.0, videoInfo.ScanlineIntensity / 100.0);
|
2018-01-07 15:52:05 -05:00
|
|
|
|
InteropEmu.SetNtscFilterSettings(videoInfo.NtscArtifacts / 100.0, videoInfo.NtscBleed / 100.0, videoInfo.NtscFringing / 100.0, videoInfo.NtscGamma / 100.0, videoInfo.NtscResolution / 100.0, videoInfo.NtscSharpness / 100.0, videoInfo.NtscMergeFields, videoInfo.NtscYFilterLength / 100.0, videoInfo.NtscIFilterLength / 100.0, videoInfo.NtscQFilterLength / 100.0, videoInfo.NtscVerticalBlend);
|
2016-05-26 22:32:20 -04:00
|
|
|
|
|
2016-05-27 17:19:23 -04:00
|
|
|
|
if(!string.IsNullOrWhiteSpace(videoInfo.PaletteData)) {
|
|
|
|
|
try {
|
|
|
|
|
byte[] palette = System.Convert.FromBase64String(videoInfo.PaletteData);
|
|
|
|
|
if(palette.Length == 64*4) {
|
|
|
|
|
InteropEmu.SetRgbPalette(palette);
|
|
|
|
|
}
|
|
|
|
|
} catch { }
|
2016-01-17 14:21:31 -05:00
|
|
|
|
}
|
2015-07-17 21:18:57 -04:00
|
|
|
|
}
|
2016-05-27 17:19:23 -04:00
|
|
|
|
|
|
|
|
|
public void AddPalette(string paletteName, byte[] paletteData)
|
|
|
|
|
{
|
|
|
|
|
string base64Data = System.Convert.ToBase64String(paletteData);
|
|
|
|
|
foreach(PaletteInfo existingPalette in this.SavedPalettes) {
|
|
|
|
|
if(existingPalette.Name == paletteName) {
|
|
|
|
|
//Update existing palette
|
|
|
|
|
existingPalette.Palette = base64Data;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(this.SavedPalettes.Count >= 5) {
|
|
|
|
|
//Remove oldest palette
|
|
|
|
|
this.SavedPalettes.RemoveAt(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PaletteInfo palette = new PaletteInfo();
|
|
|
|
|
palette.Name = paletteName;
|
|
|
|
|
palette.Palette = base64Data;
|
|
|
|
|
this.SavedPalettes.Add(palette);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Int32[] GetPalette(string paletteName)
|
|
|
|
|
{
|
|
|
|
|
foreach(PaletteInfo existingPalette in this.SavedPalettes) {
|
|
|
|
|
if(existingPalette.Name == paletteName) {
|
|
|
|
|
byte[] paletteData = System.Convert.FromBase64String(existingPalette.Palette);
|
|
|
|
|
|
|
|
|
|
int[] result = new int[paletteData.Length / sizeof(int)];
|
|
|
|
|
Buffer.BlockCopy(paletteData, 0, result, 0, paletteData.Length);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class PaletteInfo
|
|
|
|
|
{
|
|
|
|
|
public string Name;
|
|
|
|
|
public string Palette; //Base64
|
2015-07-17 21:18:57 -04:00
|
|
|
|
}
|
|
|
|
|
}
|